#!/bin/bash # aptSpy # apt install inotify-tools aptitude # https://gist.github.com/fduran/1870502 command -v inotifywait >/dev/null 2>&1 || { >&2 echo "I need inotify-tools." ; exit 1; } command -v aptitude >/dev/null 2>&1 || { >&2 echo "I need aptitude." ; exit 1; } # what file to monitor for changes # /var/log/dpkg.log file="/var/log/apt/history.log" # exit if file is not there [[ -f "$file" ]] || exit 0 # counter count=0 # a function status () { num=$(aptitude search "~U" | wc -l); if [ $num != 0 ]; then echo "$num"; fi } # spy and react spy () { while inotifywait -e modify "$file" > /dev/null 2>&1 ; do ((count+=1)) >&2 echo "something happened! $count" # should show in cli only and not in tint2 status && >&2 echo "status inside loop" done } # spy in background spy & # and at some interval while : do status && >&2 echo "status on interval" sleep 3600 done ### In tint2 you would add new E-xecutor, like #execp = new #execp_centered = 0 #execp_has_icon = 0 #execp_command = aptSpy #execp_continuous = 1 #execp_font = cuprum 13 #execp_font_color = #111111 100 #execp_padding = 8 0 0 #execp_tooltip = updates #execp_lclick_command = urxvt -e bash -c "sudo apt update && sudo apt dist-upgrade && sleep 5"