aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local/bin/pacsync
diff options
context:
space:
mode:
Diffstat (limited to 'dotfiles/.local/bin/pacsync')
-rwxr-xr-xdotfiles/.local/bin/pacsync14
1 files changed, 9 insertions, 5 deletions
diff --git a/dotfiles/.local/bin/pacsync b/dotfiles/.local/bin/pacsync
index 2e5d60f..15f2c97 100755
--- a/dotfiles/.local/bin/pacsync
+++ b/dotfiles/.local/bin/pacsync
@@ -8,6 +8,9 @@ if pidof pacman; then
exit
fi
+napp="System upgrade"
+ni="preferences-system-linux"
+
# Check several times before giving up, useful when just waking up from sleep
# since internet is usually not available right away
wget -q --tries=5 --timeout=20 --spider 1.1.1.1 > /dev/null || exit
@@ -15,19 +18,20 @@ wget -q --tries=5 --timeout=20 --spider 1.1.1.1 > /dev/null || exit
# Source the needed env variables so that it can function properly from cron
. ~/.cache/sessionenv
-notify-send " System upgrade" "Syncing repositories and downloading packages..."
+notify-send -a "$napp" -i "$ni" -e "Syncing repositories and downloading packages..."
touch ~/.cache/pacsynclive
killall -41 waybar
-sudo pacman -Syuw --noconfirm || notify-send " System upgrade" \
- "Error downloading updates. Check your internet connection or that you have the required permissions"
+if ! sudo pacman -Syuw --noconfirm; then
+ notify-send -a "$napp" -i "$ni" -u critical -t 3000 "Error downloading updates.
+fi
rm -f ~/.cache/pacsynclive
killall -41 waybar
upno=$(pacman -Qu | wc -l)
-if [ $upno -lt 0 ]; then
- notify-send " System upgrade" "Repository sync finished. $upno updates are available"
+if [ $upno -gt 0 ]; then
+ notify-send -a "$napp" -i "$ni" "Repository sync finished. $upno updates are available"
fi