From 5bd407b1451f1329e0ae1b46531c2d517e056a43 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 24 Dec 2016 16:21:01 -0500 Subject: [PATCH] os/arch (panel): display notification on new email or updates --- os/arch/.config/panel/lemons/mail | 10 ++++++++++ os/arch/.config/panel/lemons/updates | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/os/arch/.config/panel/lemons/mail b/os/arch/.config/panel/lemons/mail index ccab73e6..126ef2e4 100755 --- a/os/arch/.config/panel/lemons/mail +++ b/os/arch/.config/panel/lemons/mail @@ -23,6 +23,9 @@ get_mail() { fi } +mailtmp=/tmp/mail-count +touch "$mailtmp" + a=$(get_mail "${MAIL1_USER}" "${MAIL1_PASS}") b=$(get_mail "${MAIL2_USER}" "${MAIL2_PASS}") c=$(get_mail "${MAIL3_USER}" "${MAIL3_PASS}") @@ -33,6 +36,13 @@ color="${COLOR_FG}" case $num in [1-9]*) icon="$icon$num" + lastnum=$(<$mailtmp) + if [[ $num != $lastnum ]]; then + echo "$num" > "$mailtmp" + if (( $num > $lastnum )); then + notify-send "New messages" "You have $(( $num - $mailtmp )) new messages" + fi + fi ;; 0) color="${COLOR_DIM}" ;; diff --git a/os/arch/.config/panel/lemons/updates b/os/arch/.config/panel/lemons/updates index 5794afbe..242a205b 100755 --- a/os/arch/.config/panel/lemons/updates +++ b/os/arch/.config/panel/lemons/updates @@ -2,9 +2,19 @@ . $(dirname $0)/../panel-config +updtmp=/tmp/update-count +touch "$updtmp" + num=$({ checkupdates; cower -u; } | wc -l) if [ "$num" -gt 0 ] then + lastnum=$(<$updtmp) + if [ "$num" -ne "${lastnum:-0}" ]; then + echo "$num" > "$updtmp" + if [ "$num" -gt "${lastnum:-0}" ]; then + notify-send "$num new updates available" + fi + fi echo "U%{F${COLOR_2}}$ICON_UPD$num%{F-}" else echo "U%{F${COLOR_DIM}}$ICON_UPD%{F-}"