-
-
Save SalvatoreNoschese/093c4c17abf1f55957aff5565563b757 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# "Arch Update Checker v1.0" | https://SalvatoreNoschese.it | |
# Require: Arch + pacman-contrib + libnotify | |
# Config: | |
auc_time="1" # Check every (hours) | |
auc_delay="10" # Start delay (seconds) | |
auc_notify_time="10" # Notification time (seconds) | |
auc_title="Arch Update Checker 🔄" | |
# Set notification title based on system language | |
if [[ "${LANG}" == *"it"* ]]; then | |
auc_found="Aggiornamenti trovati" | |
auc_notfound="Nessun aggiornamento:" | |
auc_runcmd="Esegui il comando" | |
auc_recheck="Ricontrollo tra" | |
else | |
auc_found="Updates found" | |
auc_notfound="No updates:" | |
auc_runcmd="Run the command" | |
auc_recheck="Check again in" | |
fi | |
# Check if /etc/arch-release, pacman-contrib, or libnotify are missing | |
if [[ ! -f /etc/arch-release ]] || ! pacman -Qs pacman-contrib &> /dev/null || ! pacman -Qs libnotify &> /dev/null; then | |
echo "$(date +"%Y-%m-%d %H:%M:%S"): Not Arch Linux or missing dependencies!" >> "$HOME/$(basename "$0").log" | |
exit 1 | |
fi | |
# Check if another instance of the script is already running | |
lockfile="/tmp/$(basename "$0").lock" | |
if [ -f "$lockfile" ] && ps -p $(cat "$lockfile") > /dev/null; then | |
notify-send -a "$auc_title" -t "$((auc_notify_time * 1000))" -i "archlinux-logo.svg" "Exiting:" "The script is already running." | |
exit 1 | |
else | |
echo $$ > "$lockfile" | |
fi | |
# Run While | |
sleep "$auc_delay" | |
while true; do | |
# If yay or paru is installed | |
if pacman -Qs yay &> /dev/null; then | |
aur_updates=$(yay --aur -Qu | wc -l) | |
auc_infoaur="$auc_runcmd 'yay --aur -Syu'" | |
elif pacman -Qs paru &> /dev/null; then | |
aur_updates=$(paru --aur -Qu | wc -l) | |
auc_infoaur="$auc_runcmd 'paru --aur -Syu'" | |
fi | |
# Make notify | |
auc_summary="$auc_found 🔔" | |
auc_pacupdates=$(checkupdates | wc -l) | |
if [[ $auc_pacupdates -gt 0 && $aur_updates -gt 0 ]]; then | |
auc_body="<b><i>(Pacman: $auc_pacupdates + AUR: $aur_updates)</i></b>\n$auc_runcmd 'sudo pacman -Syu'\n+++\n$auc_infoaur" | |
elif [[ $auc_pacupdates -gt 0 ]]; then | |
auc_body="<b><i>(Pacman: $auc_pacupdates)</i></b>\n$auc_runcmd 'sudo pacman -Syu'" | |
elif [[ $aur_updates -gt 0 ]]; then | |
auc_body="<b><i>(AUR: $aur_updates)</i></b>\n$auc_infoaur" | |
else | |
auc_summary="$auc_notfound" | |
auc_body="$auc_recheck $auc_time hr ⏰" | |
fi | |
# Kill notify, then send again | |
dbus-send --print-reply --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.CloseNotification uint32:982313 | |
sleep "1s" # attebd just one second before send new notification | |
notify-send -a "$auc_title" -t "$((auc_notify_time * 1000))" -i "archlinux-logo.svg" -h "string:desktop-entry:org.kde.konsole" -r 982313 "$auc_summary" "$auc_body" | |
sleep "${auc_time}h" # Set by $auc_time | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Exec=/home/nomeutente/.config/ArchUpdateChecker | |
Icon=archlinux-logo.svg | |
Name=Arch Update Checker | |
Terminal=False | |
Type=Application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info here: https://salvatorenoschese.it/archupdatecheck-sh-script-download/