diff --git a/ratatoskr.sh b/ratatoskr.sh index 34baff5..d8ebbc9 100755 --- a/ratatoskr.sh +++ b/ratatoskr.sh @@ -43,12 +43,13 @@ get_oauth_token() { echo "Please open the following url in your browser." echo "Copy the generated token, and paste it here, then press enter to continue." echo - echo "${url}" - echo if command -v xclip &> /dev/null ; then - echo "${url}" | xclip -selection clipboard -d "${DISPLAY:-:0}" 2> /dev/null && - echo "For convenience the url has been copied to your clipboard." + echo "${url}" | tee >(xclip -selection clipboard -d "${DISPLAY:-:0}" 2> /dev/null && + echo "For convenience the url has been copied to your clipboard.") + else + echo "${url}" fi + echo read -er oauth_token echo "oauth_token=\"${oauth_token}\"" >> "${configPath}/${configFile}" echo "instanceURL=\"${instanceURL}\"" >> "${configPath}/${configFile}" @@ -81,6 +82,7 @@ mkdir -p "${configPath}" # Associative array of command line parameters and short description of what they do. declare -A command=( + [C]="Recreate default configuration file. Acquire new oauth token." [h]="Help, show usage information for ${0##*/}." [M]="Post the currently playing music track, requires playerctl." ) @@ -99,6 +101,7 @@ args="${!command[*]}" args="${args//[[:space:]]/}" while getopts "${args}" i ; do case "$i" in + C) get_oauth_token;; h) help;; M) post_music;; esac