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.
#!/bin/bash

TMPFILE="/tmp/updateslist"
FONT="-adobe-helvetica-medium-*-normal-*-12-*-75-*-*-*-*-*"

while :;
do
	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 &
	else
		echo -e "no updates" | dzen2 -p -h 22 -ta l -fn $FONT -bg black &
	fi
	inotifywait "/var/lib/pacman/local/"
done

Tagged as arch linux yaourt notifier dzen2

blog comments powered by Disqus