Reorganized the code that puts the url into the clipboard if possible.

This commit is contained in:
stormdragon2976 2023-01-29 16:35:08 -05:00
parent d419435462
commit 73c3ae9cc6

View File

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