Skip to content

Instantly share code, notes, and snippets.

@MeganerdNL
Last active September 20, 2026 10:00
Show Gist options
  • Select an option

  • Save MeganerdNL/077c9a968cc97ab700f0a437677009cd to your computer and use it in GitHub Desktop.

Select an option

Save MeganerdNL/077c9a968cc97ab700f0a437677009cd to your computer and use it in GitHub Desktop.
Systemd (user) services and scripts for custom check on system updates and give a notification on Bazzite. Remove the numbers in front of the filesnames, they are for ordering in the gist. There is 1 system service with a timer and 1 user service with a timer. Besides that 2 scripts that are called from the services.
## Place in /etc/systemd/system
## Service is started by the timer
[Unit]
Description=Custom Universal Blue Update Oneshot Service
StartLimitBurst=3
StartLimitIntervalSec=600
[Service]
Type=oneshot
ExecStartPre=/usr/local/bin/bat_uupd-custom.sh
ExecStart=/usr/bin/uupd --hw-check=false --json --log-level=debug
Restart=on-failure
RestartSec=60s
SELinuxContext=system_u:unconfined_r:unconfined_t:s0
## Place in /etc/systemd/system
## Disable the normal update service timer: sudo systemctl disable --now uupd.timer
## Reload daemon: sudo systemctl daemon-reload
## Enable and start: sudo systemctl enable --now uupd-custom.timer
[Unit]
Description=System Timer for Custom Universal Blue Update Oneshot Service
Wants=network-online.target
[Timer]
OnBootSec=45s
OnUnitActiveSec=2h
[Install]
WantedBy=timers.target
#!/bin/bash
## SELinux warning: Must be created by root in /usr/local/bin - NOT copied from home directory
## Must be executable (chmod +x /usr/local/bin/bat_uupd-custom.sh)
## We don't rely on the hardware checks of the service because it won't run in power save mode otherwise
## Change the path of your power supply, it's different on different hardware. Shown here is for Framework 16 laptop
bat_level=20
if [[ $(cat /sys/class/power_supply/BAT1/capacity) -ge $bat_level ]]; then
echo "Battery level greater or equal to $bat_level, go!"
exit 0
else
echo "Battery level lower than $bat_level, abort!"
exit 1
fi
## Place in ~/.config/systemd/user
## Service is started by the timer
[Unit]
Description=Check if a Bazzite system update image is installed
[Service]
Type=oneshot
ExecStartPre=/usr/local/bin/bat_uupd-custom.sh
ExecStart=%h/bin/check_updates_bazzite_installed.sh
[Install]
WantedBy=default.target
## Place in ~/.config/systemd/user
## Reload daemon (non-root): systemctl --user daemon-reload
## Enable and start (non-root): systemctl --user enable --now check_updates_bazzite_installed.timer
[Unit]
Description=Timer for "Check if a Bazzite system update image is installed"
[Timer]
OnBootSec=10m
OnBootSec=15m
OnUnitActiveSec=1h
[Install]
WantedBy=timers.target
#!/bin/bash
## Place in ~/bin
## Must be executable (chmod +x ~/bin/check_updates_bazzite_installed.sh)
## The /tmp directory is emptied after every reboot
placeholder=/tmp/update_notification_sent
# if placeholder exists and is older than some time, remove it
if [[ -f $placeholder ]]; then
some_time_ago=$(date -d 'now - 2 hours' +%s)
file_time=$(date -r "$placeholder" +%s)
if [[ $file_time -lt $some_time_ago ]]; then
echo "Removing placeholder, it's older than some time. Send notification again."
rm $placeholder
fi
fi
# if placeholder exists do nothing
if [[ -f $placeholder ]]; then
echo "Placeholder in place, dont send notification."
exit 0
fi
# Check for update on system image
if rpm-ostree status -v | grep -q "Staged: yes"; then
echo "A new system image was installed. Send notification."
notify-send -u critical -a "Bazzite OS" "Bazzite system update installed" "A new system image was installed. Please reboot." --icon=system-software-update
echo "Make placeholder, don't send notification for some time."
touch $placeholder
else
echo "No new system image was installed."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment