scarpino.dev

Hey, you've N outofdated packages!

I know…I should study instead of writing these stuff.

Anyway, I lost only 15 minutes to set up this:

I googled a bit around looking for a system tray notification applet for Arch Linux and I found many (alunn, pacman-notifier, yapan, zenman…), but some project is dead, someone uses (Py)GTK, someone requires to edit the sudoers file or to grant permissions to your package manager.

Not what I was looking for.

Then, I used 2 cron jobs to display a notify every hour using kdialog only if there are outofdated packages in the system.

The first one script updates the pacman database and goes in /etc/cron.hourly/:

#!/bin/sh
/usr/bin/pacman --sync --refresh

Easy enough.

Then create this script somewhere and add it to your user crontab:

#!/bin/bash
pkgs=$(pacman -Qqu | wc -l)
aurpkgs=$(cower -ud | wc -l)

unset msg1
unset msg2
unset packages

if [[ ${pkgs} -gt 0 ]]; then
msg1="${pkgs} in pacman"
fi

if [[ ${aurpkgs} -gt 0 ]]; then
msg2=" ${aurpkgs} in AUR"
fi

let packages=${pkgs}+${aurpkgs}
if [[ ${packages} -gt 0 ]]; then
kdialog --title "Out-of-Date packages" --passivepopup "There are ${packages} outofdated packages (${msg1}${msg2})" 10
fi

exit 0

cower is my favorite AUR agent; edit the script to use your.

It’s rude, but it works and does its job.

Bye!

Note: when I was googling I found some user that had the “fantastic” idea to use cron to update its system. Please don’t do it! Really, you MUST read the output of your package manager. Ever.

Tags: arch linux, howto, kde

By Andrea Scarpino on 2011-02-06

Discuss on HackerNews