[Tutorial] systemd timer that can send a notification:

This has taken me nearly a day and a lot of reading to get it to work!

Scenario - I wanted a notification every n minutes of any updates available, but this is easily adapted to other uses, just change the script.

  1. The script (uses auracle & checkupdates):
#!/usr/bin/env bash

# Run by /etc/systemd/system/archup.service + timer

export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$UID/bus"

echo $(date) > ~/.avail.txt

/usr/bin/checkupdates >> ~/.avail.txt

echo "-----------------------------------------------" >> ~/.avail.txt

/usr/bin/auracle outdated >> ~/.avail.txt

notify-send "$(cat ~/.avail.txt)"

echo $(date) >> ~/test 

The export DBUS_SESSION… is the important line, if it is missing, the following error occurs:

Cannot autolaunch D-Bus without X11 $DISPLAY
  1. The service:
# /etc/systemd/system/archup.service
Description=Service to run update notifier:


The important line here is User=<your-user>. /usr/bin/uup is a symlink to the script.

  1. The Timer:
# /etc/systemd/system/archup.timer
Description=Logs some system statistics to the systemd journal


# Explained https://silentlad.com/systemd-timers-oncalendar-(cron)-format-explained

# Testing - Every 1 minute:

# Deployment - Every 30 minutes:


  1. Start the timer:
sudo systemctl enable archup.timer --now

A notification can be forced with:

sudo systemctl restart archup.timer


Am now working on a gmail script, will post it when I get it working…

why not simply use the eos-update-notifier package from the repo?

If you want more functions in there, you might be able to contribute to that one as it is EndeavourOS maintained.

Because I am trying to learn eww and needed something to integrate with it.

What is that?

:face_vomiting: :sweat_smile:

Learning is always a good thing. But I don’t understand why you’re adding in extra hoops here. As mentioned above, the eos-update-notifier script will generate a notification for the current user…because the systemd service the timer calls is run as a user service, installed in $HOME/.config/systemd/user. If you look at the service, you’ll that it only needs to add the DISPLAY=:0 variable to the environment before running:

# /home/ajgringo619/.config/systemd/user/eos-update-notifier.service
Description=EOS update notifier service

ExecStart=/usr/bin/eos-update-notifier -systemd


IMHO, a better project would be to learn about sending system notifications to logged in users.

When learning an instrument, we are taught to play the same notes as someone else. When we do it well enough, and like it, we experiment and make our own music.

In other words, we learn to recreate something from scratch that has already been made so we can create something entirely new. :thinking: