diff --git a/znotif/znotif b/znotif/znotif index 5ae5ad2..93a0651 100755 --- a/znotif/znotif +++ b/znotif/znotif @@ -11,7 +11,8 @@ Sends notification when the given command finished executing -t Time the notification stays. By default 2 -T Notification title -m <string> Displays this message when finished. Variable resolution on - > Default message is '<command> finished'" + > Default message is '<command> finished' + -y Display a yes/no prompt instead. Time doesn't apply" } warning () { @@ -25,42 +26,46 @@ error () { _args="" -# $1 = message , $2 = time , $3 = title +# $1 = message , $2 = title , $3 = time notify () { if which kdialog >/dev/null then - kdialog --passivepopup "$1" $2 --title "$3" + kdialog --passivepopup "$1" "$3" --title "$2" elif which notify-send >/dev/null then - notify-send -t $2 "$3" "$1" + notify-send -t "$3" "$2" "$1" else echo "No supported notification" >&2 && return 1 fi } +yesno () { + if which kdialog >/dev/null + then + kdialog --yesno "$1" --title "$2" + elif which zenity + then + zenity --question --text="$1" --title="$2" + else "No supported prompt" + fi +} + # read options -while getopts ":hm:T:t:" opt; +while getopts ":hym:T:t:" opt; do case $opt in h) usage - exit 0 + exit 1 ;; + y) _opt_y=y ;; m) - if [ ! -n "$OPTARG" ] - then - error "m needs an argument" - exit - fi + [ ! -n "$OPTARG" ] && { error "m needs an argument" ; exit 2; } message=$OPTARG _opt_m=y ;; - T) title="$OPTARG" ;; - t) _arg_t="$OPTARG" ;; - \?) - echo "Uknown option: $OPTARG" - usage - exit 1 - ;; + T) title=$OPTARG ;; + t) _arg_t=$OPTARG ;; + \?) echo "Uknown option: $OPTARG" && usage && exit 2 ;; esac done @@ -76,4 +81,9 @@ else [ -z "$title" ] && title="Ping" fi -notify "$message" $_arg_t "$title" +if [ -n "$_opt_y" ] +then + yesno "$message" "$title" +else + notify "$message" "$title" "$_arg_t" +fi diff --git a/zrct2/zrct2-install b/zrct2/zrct2-install index 4326ddc..2d5dbc5 100755 --- a/zrct2/zrct2-install +++ b/zrct2/zrct2-install @@ -31,9 +31,9 @@ abort() exit "$1" } -APT_PACKAGES="gcc g++ git make cmake libsdl2-dev libicu-dev pkg-config libjansson-dev libspeex-dev libspeexdsp-dev libcurl4-openssl-dev libcrypto++-dev libfontconfig1-dev libfreetype6-dev libpng-dev libssl-dev libzip-dev duktape-dev" +APT_PACKAGES="gcc g++ git make cmake libsdl2-dev libicu-dev pkg-config libjansson-dev libspeex-dev libspeexdsp-dev libcurl4-openssl-dev libcrypto++-dev libfontconfig1-dev libfreetype6-dev libpng-dev libssl-dev libzip-dev" DNF_PACKAGES="gcc gcc-c++ jansson-devel openssl-devel SDL2-devel libicu-devel speexdsp-devel libcurl-devel cmake fontconfig-devel freetype-devel libpng-devel libzip-devel mesa-libGL-devel" -PACMAN_PACKAGES="gcc gcc-libs git cmake sdl2 fontconfig libzip libpng curl jansson speexdsp openssl icu duktape" +PACMAN_PACKAGES="gcc gcc-libs git cmake sdl2 fontconfig libzip libpng curl jansson speexdsp openssl icu" echo_white "Installing packages" if which apt >/dev/null 2>&1 diff --git a/zupdate/sysupdate b/zupdate/sysupdate index 308cbec..cfa2884 100755 --- a/zupdate/sysupdate +++ b/zupdate/sysupdate @@ -2,7 +2,7 @@ linuxpkgnames="" -lock_file=/tmp/update.lock +lock_file=/tmp/sysupdate.lock get_running_programs() { @@ -22,17 +22,18 @@ stop() fetch_error() { echo "Error: Could not fetch packages" > /dev/stderr - kdialog --passivepopup "Error during system updates: could not fetch packages" 60 --title "System Updates" + znotif -T "System updates" -t 120 -m "Error during system updates: could not fetch packages" stop 3 } update_error() { echo "Error: Could not upgrade system" > /dev/stderr - kdialog --passivepopup "Error during system updates: could not upgrade" 60 --title "System Updates" + znotif -T "System updates" -t 120 -m "Error during system updates: could not upgrade" stop 3 } +which zupdate >/dev/null || { echo "zupdate not installed" >&2; exit 4; } # Check if another process is running if [ -n "$(pgrep zupdate)" ] || [ -f "$lock_file" ] @@ -42,8 +43,6 @@ then fi touch "$lock_file" -which zupdate >/dev/null || { echo "zupdate not installed" >&2; stop 4; } - # package manager specific variables if which apt >/dev/null 2>&1 then @@ -72,17 +71,17 @@ fi running_programs=$(get_running_programs "$packages") if [ -n "$running_programs" ] then - if ! kdialog --yesno "The following running programs have recieved updates: \n$(echo "$running_programs" | sed 's|^| - |g')" --yes-label "Continue" --no-label "Cancel" --title "Updates" + if ! znotif -T "System Updates" -y -m "The following running programs have recieved updates: \n$(echo "$running_programs" | sed 's|^| - |g')\nProceed?" then echo "Update cancelled" > /dev/stderr stop 3 fi fi -kdialog --passivepopup "Installing updates for $size download" 10 --title "System Updates" +znotif -T "System Updates" -t 10 -m "Installing updates for $size download" #update zupdate -yu || update_error #end update -kdialog --passivepopup "Updates finished" 5 --title "System Updates" +znotif -T "System Updates" -t 5 -m "Updates finished" stop 0