Replacing Plasma Discover Update Notifier

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

I did not try to read and understand fully all you scripted. But I am always wondering why people are so fond of zypper ref. When you do most zypper actions, an automatic refresh is done for all repos that have autorefresh on. That is where that parameter is for. There is however a timer (default 10 minutes) that prevents a refresh from being done again. Normally that is fine. And when one thinks it is needed to refresh within those 10 minutes, zypper ref is there. But doing it the whole time? I really wonder.

1 Like

I am only refreshing the repos on boot and using that command because it doesn’t automatically happen when using zypper lu. AFAIK there are nothing else automatically refreshing the repos, I have now removed discover. Other than that, I’ve barely used zypper ref before because like you say, it is done automatically with dup commands or when loading myrlyn.