aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local/bin/pacsync
diff options
context:
space:
mode:
authorYaroslav <contact@yaroslavps.com>2020-04-09 01:30:04 +0300
committerYaroslav <contact@yaroslavps.com>2020-04-09 01:30:04 +0300
commitd5c97e78d80177119421f9dade324b04f2b00126 (patch)
tree7a637bf2a8ea613f7480301434e778ad6d8b6f42 /dotfiles/.local/bin/pacsync
parent2a7d8cecace432898722b0d2c7a2543e1057cf74 (diff)
downloadswayrice-d5c97e78d80177119421f9dade324b04f2b00126.tar.gz
swayrice-d5c97e78d80177119421f9dade324b04f2b00126.zip
mail scripts for aerc+mbsync; goodbye neomutt
Diffstat (limited to 'dotfiles/.local/bin/pacsync')
-rwxr-xr-xdotfiles/.local/bin/pacsync9
1 files changed, 6 insertions, 3 deletions
diff --git a/dotfiles/.local/bin/pacsync b/dotfiles/.local/bin/pacsync
index f96996a..9e745c8 100755
--- a/dotfiles/.local/bin/pacsync
+++ b/dotfiles/.local/bin/pacsync
@@ -1,5 +1,8 @@
#!/bin/sh
+# Run only if user logged in (prevent cron errors)
+w | grep "^$USER\W" >/dev/null || exit
+
# Don't try to sync if pacman is already running
if pidof pacman; then
exit
@@ -12,12 +15,12 @@ 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 " System upgrade" "Syncing repositories and downloading packages..."
touch ~/.cache/pacsynclive
killall -41 waybar
-sudo pacman -Syuw --noconfirm || notify-send " System upgrade" \
+sudo pacman -Syuw --noconfirm || notify-send " System upgrade" \
"Error downloading updates. Check your internet connection or that you have the required permissions"
rm -f ~/.cache/pacsynclive
@@ -26,5 +29,5 @@ killall -41 waybar
upno=$(pacman -Qu | wc -l)
if [ $upno -lt 0 ]; then
- notify-send " System upgrade" "Repository sync finished. $upno updates are available"
+ notify-send " System upgrade" "Repository sync finished. $upno updates are available"
fi