#!/bin/bash # Get the current user user=$USER # Ensure we have a user if [ -z "$user" ]; then echo "No user specified" | systemd-cat -t zypper-auto-update -p err exit 1 fi # Wait a few seconds for the session to be fully initialized sleep 5 # Check if either service failed if systemctl is-failed --quiet zypper-refresh-download.service || \ systemctl is-failed --quiet zypper-offline-update.service; then sudo -u $user DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $user)/bus \ notify-send -a "Zypper Auto Update" -u critical "Zypper Update Failed" "One of the Zypper services has failed. Please check the logs." else # Optionally notify of success sudo -u $user DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u $user)/bus \ notify-send -a "Zypper Auto Update" "Zypper Update Status" "System updates are working normally." fi exit 0