I have never liked Plasma Discover and much prefer to use terminal and Myrlyn. I have kept it on my system because of the update notifier. This permanently occupies a couple of hundred mb of ram, all the time which I think is a bit much for the task. So I decided to to script it at reboot to refresh zypper, then pipe the output of zypper lu to the notifications so it tells me how many updates are available. I used gemini LLM to help me do this (vibe scripting? I didn’t feel a thing)
The initial task is to make zypper refresh run at startup, so I made a file called zypper-refresh.service in the folder /etc/systemd/system which contains the following text
Description=Run zypper refresh at boot
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/zypper refresh
Nice=10
[Install]
WantedBy=multi-user.target
I then ran the following commands: sudo systemctl daemon-reload and sudo systemctl enable --now zypper-refresh.service
Further commans can be run without sudo permissions, so the rest is done with the following bash script.
#!/bin/bash
sleep 1m
# 1. Get the update count safely
# We use grep -c and then force it to a clean integer
update_count=$(zypper lu | grep -c '^v' | tr -d -c '0-9')
# Check if the variable is empty or not a number, default to 0
if [ -z "$update_count" ]; then update_count=0; fi
# Exit if no updates
if [ "$update_count" -le 0 ]; then
exit 0
fi
# 2. Send the notification via busctl
# Parameters:
# "Zypper Monitor" (App Name) | 0 (Replaces ID) | "software-update-available" (Icon)
# "System Updates" (Summary) | "There are $update_count updates available." (Body)
# 0 (No actions) | 0 (No hints) | 5000 (Timeout in ms)
busctl --user call org.freedesktop.Notifications \
/org/freedesktop/Notifications \
org.freedesktop.Notifications \
Notify \
susssasa{sv}i \
"Zypper Monitor" 0 "openSUSE-distributor-logo" \
"System Updates" "There are $update_count updates available." \
0 0 5000
I will say the LLM was quite good at putting explanatory comments on the script. I put the sleep 1m at the beginning to give time to make sure the zypper refresh has completed.
I used the autostart section in the system settings to set the script to run at login.
I tried to use kcron to run zypper refresh at boot but the system level jobs just disappear at every boot.
It works anyway. At boot if there are any updates, I get a notification with the opensuse logo telling me how many updates are available. This stays in the notification history too.
Any comments welcome