24 July 2010

arch linux update notifier for dzen2

First we need a cronjob to sync the package lists: Create the file ~/path/to/updates.cron. This, of course depends on yaourt:
0, *, *, *, * yaourt -Sy

…and add the crontab entry:
sudo crontab "~/path/to/updates.cron" -u root
That will sync the package lists at the beginning of every hour.

The following shell script will detect when the package database has been accessed and update dzen2 accordingly. It depends on inotify-tools.


while :;
	po=$(yaourt -Qu --aur 2> "/dev/null" | tee "/tmp/updateslist" | wc -l)

	if [ "$po" -gt 1 ]; then # found some
		echo -e "^fg(#FF0000)$po updates^fg()\n$(cat $TMPFILE)" | dzen2 -p -h 22 -ta l -l $po -fn $FONT -bg black &
	elif [ "$po" -eq 1 ]; then # found something
		echo -e "^fg(#FF0000)1 update^fg()\n$(cat $TMPFILE)" | dzen2 -p -h 22 -ta l -l $po -fn $FONT -bg black &
		echo -e "no updates" | dzen2 -p -h 22 -ta l -fn $FONT -bg black &
	inotifywait "/var/lib/pacman/local/"

Tagged as arch linux yaourt notifier dzen2

blog comments powered by Disqus