tubetop2: Check flags earlier on, adjust notification priorities

This commit is contained in:
Salt 2018-08-19 19:59:48 -05:00
parent 05fda57bf7
commit becbd2b639

View File

@ -29,18 +29,18 @@ function tubetop2-download {
notify-high "Error" "An error occured while downloading $1. youtube-dl gave error code $errorcode." "dialog-error" notify-high "Error" "An error occured while downloading $1. youtube-dl gave error code $errorcode." "dialog-error"
return $errorcode return $errorcode
fi 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 return 0
} }
function notify-normal { function notify-normal {
if [ -z ${1+x} ] || [ -z ${2+x} ] || [ -z ${3+x} ]; then return 1; fi 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 { function notify-high {
if [ -z ${1+x} ] || [ -z ${2+x} ] || [ -z ${3+x} ]; then return 1; fi 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 { function log {
@ -50,6 +50,19 @@ function log {
name="$(basename $0 .bash)" 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 # Figure out where to store the videos
if [ -z ${XDG_DATA_HOME+x} ]; then if [ -z ${XDG_DATA_HOME+x} ]; then
cachedir="$HOME/.local/share/$name" cachedir="$HOME/.local/share/$name"
@ -71,18 +84,6 @@ if ! [ -f "$cachedir/.symlink" ] && [ -d "$HOME/Videos" ]; then
touch "$cachedir/.symlink" touch "$cachedir/.symlink"
fi 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 # Get a list of all the videos we have
log 3 "Getting a list of videos" log 3 "Getting a list of videos"
videos=$(find "$cachedir" -type f -name \*.mp4) videos=$(find "$cachedir" -type f -name \*.mp4)