From becbd2b639a5f90f96edcf1ae4da4fac8837d69c Mon Sep 17 00:00:00 2001 From: Salt Date: Sun, 19 Aug 2018 19:59:48 -0500 Subject: [PATCH] tubetop2: Check flags earlier on, adjust notification priorities --- tubetop2.bash | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tubetop2.bash b/tubetop2.bash index 8a00f95..c2e7fe3 100755 --- a/tubetop2.bash +++ b/tubetop2.bash @@ -29,18 +29,18 @@ function tubetop2-download { notify-high "Error" "An error occured while downloading $1. youtube-dl gave error code $errorcode." "dialog-error" return $errorcode fi - notify-high "Download Finished" "\"$videoname\" is now ready to be embedded." "dialog-information" + notify-normal "Download Finished" "\"$videoname\" is now ready to be embedded." "dialog-information" return 0 } function notify-normal { if [ -z ${1+x} ] || [ -z ${2+x} ] || [ -z ${3+x} ]; then return 1; fi - notify-send -u low -t 3000 -i "$3" -a "$name" "$1" "$2" + notify-send -u normal -t 3000 -i "$3" -a "$name" "$1" "$2" } function notify-high { if [ -z ${1+x} ] || [ -z ${2+x} ] || [ -z ${3+x} ]; then return 1; fi - notify-send -u normal -t 10000 -i "$3" -a "$name" "$1" "$2" + notify-send -u high -t 10000 -i "$3" -a "$name" "$1" "$2" } function log { @@ -50,6 +50,19 @@ function log { name="$(basename $0 .bash)" +# If we were called with --kill, kill all running tubetops +if [ "$1" == "--kill" ]; then + log 3 "Launched in kill mode. Killing xwinwrap" + if pkill xwinwrap; then + notify-normal "Stopped" "Stopped playing all embedded desktop videos" "user-trash" + log 3 "Successfully killed xwinwrap" + exit 0 + else + log 0 "Could not find any instances of xwinwrap" + exit 1 + fi +fi + # Figure out where to store the videos if [ -z ${XDG_DATA_HOME+x} ]; then cachedir="$HOME/.local/share/$name" @@ -71,18 +84,6 @@ if ! [ -f "$cachedir/.symlink" ] && [ -d "$HOME/Videos" ]; then touch "$cachedir/.symlink" fi -# If we were called with --kill, kill all running tubetops -if [ "$1" == "--kill" ]; then - log 3 "Launched in kill mode. Killing xwinwrap" - if pkill xwinwrap; then - notify-high "Stopped" "Stopped playing all embedded desktop videos" "user-trash" - exit 0 - else - log 0 "Could not find any instances of xwinwrap" - exit 1 - fi -fi - # Get a list of all the videos we have log 3 "Getting a list of videos" videos=$(find "$cachedir" -type f -name \*.mp4)