From a6ef0dd7a2875319bb787f581ed0f38f80c7a546 Mon Sep 17 00:00:00 2001 From: paperbenni Date: Mon, 3 Aug 2020 23:07:18 +0200 Subject: [PATCH] add update notifier --- programs/instantupdatenotify | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 programs/instantupdatenotify diff --git a/programs/instantupdatenotify b/programs/instantupdatenotify new file mode 100644 index 0000000..ee52e15 --- /dev/null +++ b/programs/instantupdatenotify @@ -0,0 +1,41 @@ +#!/bin/bash + +# check for updates and add a little notification to the top offering to install them + +UPDATECOUNT="$(checkupdates | wc -l)" + +if ! [ "$UPDATECOUNT" -gt 1 ]; then + echo "no updates available" + exit +fi + +echo ">>h Update Notifier +> there are +> $UPDATECOUNT updates available +> ---- +:gupdate now +:rlater" | instantmenu -G -q 'notification' -l 20 -x 10000 -y -1 -w -1 -bw 5 >/tmp/updatechoice & + +export TMPPID="$!" +echo "tmpid $TMPPID" +COUNTER='.' + +while ! grep -q '..................' <<<"$COUNTER":; do + sleep 1 + echo "waiting for selection $COUNTER" + COUNTER="$COUNTER." + if ! kill -0 "$TMPPID" &>/dev/null; then + echo "menu quit" + break + fi +done + +if grep -q '..' /tmp/updatechoice; then + if grep 'update now' /tmp/updatechoice; then + ~/.config/instantos/default/terminal -e sh -c yay + fi +else + kill "$TMPPID" +fi + +rm /tmp/updatechoice -- 2.11.0