diff --git a/play-lofi b/play-lofi index 9986cb6..05da14b 100755 --- a/play-lofi +++ b/play-lofi @@ -23,6 +23,19 @@ link_file="$XDG_CONFIG_HOME/lofi-link" +print_help() { + echo "USAGE: play-lofi [commands] +A program to play a lofi stream from Invidious (a YouTube proxy). When +given no options, it plays from the stream URL in '\$XDG_CONFIG_HOME/ +lofi-link'. If the file does not exist it will give you a selection of +streams to choose from. + +Commands: + new choose a new stream URL + set set stream URL + help show this help information" +} + new_link() { local results=$(curl -s "https://invidio.us/search?q=lofi+radio" | grep "

.*watch" | tr -d "\n" | tr -s " ") @@ -55,6 +68,35 @@ new_link() { echo $link > $link_file } +# argument parsing +if [ "$#" -eq "1" ] +then + case $1 in + "help") + print_help + exit 0;; + "new") + new_link;; + *) + echo "Unknown command '$1'. Run 'play-lofi help' for a list of commands." + exit 1;; + esac +elif [ "$#" -eq "2" ] +then + if [ "$1" = "set" ] + then + echo "$2" > $link_file + exit 0 + else + echo "Unknown command '$1 $2'. Run 'play-lofi help' for a list of commands." + exit 1 + fi +elif [ "$#" -gt "2" ] +then + echo "Too many arguments. Run 'play-lofi help' for a list of commands." + exit 1 +fi + # check for link file if ! [ -e "$link_file" ] then