Archlinux provides an handy script called checkupdates, to check for available pacman updates without requiring the root password. This post will explain how to use this tool to automatically get a nice notification whenever new updates are ready to be installed.

The notifier script

Create a simple script that runs checkupdates and sends a notification if necessary:

#!/usr/bin/env bash
n=$(checkupdates | wc -l)
if [ "$n" != "0" ]; then
    notify-send "System update" "$n updates available."
fi

Put this script in a location in your $PATH and make sure is executable. In this example I will use ~/bin/updates-notifier.sh.

Periodically run the script

We are going to use systemd timer to periodically execute the script. Systemd timers are easy to create (I hate the syntax of cron!) and don’t require root privileges.

Create the service file

Create the file ~/.config/systemd/user/updates-notifier.service with the following content:

[Unit]
Description=Check and notify pacman updates

[Service]
Type=simple
# replace the path of your notifier script
ExecStart=/home/elvis/bin/updates-notifier.sh

This will take care to execute the notifier script.

Create the timer file

Create the file ~/.config/systemd/user/updates-notifier.timer with the following content:

[Unit]
Description=Runs updates-notifier.service every hour

[Timer]
# Time to wait after booting before we run first time
OnBootSec=5min
# Time between running each consecutive time
OnUnitActiveSec=1h
Unit=updates-notifier.service

[Install]
WantedBy=timers.target

This timer will simply trigger the updates-notifier.service every hour.

Enable the timer

Just run:

$ systemctl --user start updates-notifier.timer

This is the resulting notification in a Plasma desktop!

Example of pacman notification