DNF Update Notifier
A lightweight Bash script to notify you of available DNF package updates at a specified interval on Fedora systems. It integrates with the desktop environment using notify-send and allows you to update packages directly via a terminal prompt.
Features
- Runs
dnf check-updatesilently in the background - Sends a desktop notification if updates are available
- Optional action to open a terminal and run
dnf update - Automatically executed periodically using a cron job.
- Retry option included in case of update check errors
- Logs error details for troubleshooting
Notification Preview
Here’s how the desktop notifications look in different scenarios: when updates are available, when the system is up to date, and when an error occurs during the update check.
| Updates available | System up-to-date | Error |
|---|---|---|
Installation
-
Clone the repository:
$ git clone https://github.com/michielskobe/dnf-update-notifier.git $ cd dnf-update-notifier -
Move the script to the correct location and make it executable:
$ mv dnf-update-notifier.sh /path/to/dnf-update-notifier.sh $ chmod +x /path/to/dnf-update-notifier.sh -
Add a cron job to run the script automatically:
- Open your user crontab:
$ crontab -e - Add the following line to run the script every minute:
```bash
-
-
-
-
- /path/to/dnf-update-notifier.sh ```
-
-
-
-
-
Save and exit the editor. The script will now run automatically at the specified interval.
- Verify that the cron job was added successfully:
$ crontab -l
- Open your user crontab:
Customizations
-
Cron interval vs script execution:
The example cron job runs the script every minute (every minute of every hour, every day). Inside the script, a check ensures that the update check executes only once every 24 hours. This approach has two advantages:
-
No missed checks - if the system is powered off when a scheduled cron execution would occur, the script will still run the next time the system is on, so updates are never skipped.
-
Avoids unnecessary notifications - even though the cron job may trigger frequently, the script itself enforces the interval, preventing repeated notifications within the same 24-hour period.
You can adjust the frequency by modifying the
INTERVALvariable insidednf-update-notifier.sh, allowing you to balance timely update checks with minimal notification noise. -
-
Custom terminal emulator:
If you want to use a different terminal emulator, edit the line near the bottom of
dnf-update-notifier.sh:ptyxis -- "$SHELL" -c "sudo dnf update; exec $SHELL"Replace
ptyxiswith your preferred terminal command. -
Custom text editor for logs:
If you want to use a different text editor to inspect the error log, edit the line near the bottom of
dnf-update-notifier.sh:gnome-text-editor /path/to/dnf-update-notifier.logReplace
gnome-text-editorwith your preferred editor.
Uninstall
-
Remove the script:
$ rm /path/to/dnf-update-notifier.sh -
Remove the cron job by editing your crontab and deleting the corresponding line:
$ crontab -e