A quick bash script that does this. There is no need to install additional apps to your system for things like this. But it is your system, so your rules and needs are what matter.
#!/bin/bash
# Function to check for updates and send notification
check_updates() {
updates=$(checkupdates && paru -Qua)
if [ -n "$updates" ]; then
notify-send -t 60000 -a "System Updates" "Updates Available" "Click to update in your terminal" -A "Update"
if [ $? -eq 0 ]; then
# Notification was clicked, launch alacritty and run pacman and yay
alacritty -H -e "bash -c 'sudo pacman -Syu && yay -Sua; echo; read -p \"Press Enter to close this window...\"'"
fi
fi
}
# Main loop
while true; do
check_updates
sleep 6h
done
This script does the following:
- It defines a function called
check_updates
that:
- Runs
checkupdates && paru -Qua
to check for both official repository and AUR updates - If updates are found, it sends a notification using
notify-send
that lasts for 60 seconds (60000 milliseconds)* . - If the notification is clicked, it launches the Alacritty terminal and runs
sudo pacman -Syu && yay -Sua
*. - The main loop runs the
check_updates
function and then sleeps for 6 hours before repeating
To use this script:
- Save it to a file, for example
update_checker.sh
. - Make it executable with
chmod +x update_checker.sh
. - Run it in the background with
./update_checker.sh &
.
Note that this script assumes:
- You have
checkupdates
,paru
,notify-send
,alacritty
, andyay
installed on your system. - You’re using Alacritty as your terminal. If you prefer a different terminal, replace
alacritty
with your preferred terminal command.
To make this script run automatically at startup, you can add it to your window manager’s autostart configuration or create a systemd user service. Remember that running automatic update checks and notifications can be resource-intensive, so adjust the frequency as needed for your system.