Checks if a NVIDIA driver is staged, if so will send a notification
nano $HOME/Documents/reboot_check.sh
#!/usr/bin/env bash
set -u
reasons=()
if command -v rpm-ostree >/dev/null 2>&1; then
rpm-ostree status --pending-exit-77 >/dev/null 2>&1
[[ $? -eq 77 ]] &&
reasons+=("A new system deployment is staged.")
fi
if command -v nvidia-smi >/dev/null 2>&1 &&
command -v flatpak >/dev/null 2>&1; then
host_version="$(
nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null |
head -n1 | tr -d '[:space:]'
)"
if [[ -n "$host_version" ]]; then
required_version="${host_version//./-}"
installed_versions="$(
flatpak list --columns=application 2>/dev/null |
sed -nE 's/^org\.freedesktop\.Platform\.GL(32)?\.nvidia-//p' |
sort -u
)"
if [[ -n "$installed_versions" ]] &&
! grep -qx "$required_version" <<<"$installed_versions"; then
reasons+=(
"NVIDIA driver $host_version is running, but its matching Flatpak runtime is not installed."
)
fi
fi
fi
if ((${#reasons[@]})); then
body="$(printf '• %s\n' "${reasons[@]}")"
kdialog --title "Restart recommended" \
--passivepopup "$body" 15 >/dev/null 2>&1
exit 1
fi
kdialog --title "Restart check complete" \
--passivepopup "No restart is currently needed." 10 >/dev/null 2>&1#!/usr/bin/env bash
set -u
reasons=()
if command -v rpm-ostree >/dev/null 2>&1; then
rpm-ostree status --pending-exit-77 >/dev/null 2>&1
[[ $? -eq 77 ]] &&
reasons+=("A new system deployment is staged.")
fi
if command -v nvidia-smi >/dev/null 2>&1 &&
command -v flatpak >/dev/null 2>&1; then
host_version="$(
nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null |
head -n1 | tr -d '[:space:]'
)"
if [[ -n "$host_version" ]]; then
required_version="${host_version//./-}"
installed_versions="$(
flatpak list --columns=application 2>/dev/null |
sed -nE 's/^org\.freedesktop\.Platform\.GL(32)?\.nvidia-//p' |
sort -u
)"
if [[ -n "$installed_versions" ]] &&
! grep -qx "$required_version" <<<"$installed_versions"; then
reasons+=(
"NVIDIA driver $host_version is running, but its matching Flatpak runtime is not installed."
)
fi
fi
fi
if ((${#reasons[@]})); then
body="$(printf '• %s\n' "${reasons[@]}")"
notify-send --app-name="Restart Check" --urgency=critical \
--icon=system-reboot "Restart recommended" "$body"
exit 1
fi
notify-send --app-name="Restart Check" --urgency=normal \
--icon=emblem-default "Restart check complete" \
"No restart is currently needed."let's not run these manually. Since updates run automatically 15 minutes after boot we'll run these notifications 18 minutes after boot
write this as a user .service and user .timer
chmod +x $HOME/Documents/reboot_check.shmkdir -p $HOME/.config/systemd/user/nano $HOME/.config/systemd/user/reboot_check.timer
[Unit]
Description=Run reboot check after boot
[Timer]
OnBootSec=18min
Unit=reboot_check.service
Persistent=false
[Install]
WantedBy=timers.targetnano $HOME/.config/systemd/user/reboot_check.service
[Unit]
Description=Check whether a reboot is needed
[Service]
Type=oneshot
ExecStart=%h/Documents/reboot_check.shsystemctl --user enable --now reboot_check.timer