diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2021-06-10 08:15:24 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2021-06-10 08:15:24 +0000 |
| commit | 2ee4672b82bddf7e78aff7a2ef212f495debadac (patch) | |
| tree | 9ce6557e5cd666dddbb4e26c377c75451cc0df6f /.local/bin/statusbar/checkupdates | |
| parent | cd9049c5033f2c403bfdae1e997790d67523d1ba (diff) | |
Update statusbar scripts
Diffstat (limited to '.local/bin/statusbar/checkupdates')
| -rwxr-xr-x | .local/bin/statusbar/checkupdates | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/.local/bin/statusbar/checkupdates b/.local/bin/statusbar/checkupdates index 5a95974..dfcec84 100755 --- a/.local/bin/statusbar/checkupdates +++ b/.local/bin/statusbar/checkupdates @@ -1,15 +1,21 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -e updates=$(pacman -Qu | sed '/\[ignored\]$/d') +COUNT=$(echo -n "${updates}" | wc -l) -case $BLOCK_BUTTON in - 1) ;& # fallthrough - 3) if [ -n "${updates}" ]; then - notify-send -t $((1000 * 20)) "Available updates" "$updates" - else - notify-send "Available updates" "No available updates" - fi;; +ARG=${1:-$BLOCK_BUTTON} + +case $ARG in + 1) if [ -n "${updates}" ]; then + notify-send -t $((1000 * 20)) "Available updates (${COUNT})" "$updates" + else + notify-send "Available updates" "No available updates" + fi;; esac -[ -n "$updates" ] && echo $(echo "${updates}" | wc -l) || exit 0 +[ -z "${updates}" ] && exit + +[[ "${updates}" =~ .*linux.* ]] && echo -ne '\x0d' || echo -ne '\x0e' +[ "$COUNT" -gt 0 ] && echo -ne "$COUNT" || exit 0 +echo -ne '\x0b' |
