From 2ee4672b82bddf7e78aff7a2ef212f495debadac Mon Sep 17 00:00:00 2001 From: 0scar Date: Thu, 10 Jun 2021 10:15:24 +0200 Subject: Update statusbar scripts --- .local/bin/statusbar/checkupdates | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to '.local/bin/statusbar/checkupdates') 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' -- cgit v1.3