summaryrefslogtreecommitdiff
path: root/bin/mailsync
diff options
context:
space:
mode:
Diffstat (limited to 'bin/mailsync')
-rwxr-xr-xbin/mailsync10
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/mailsync b/bin/mailsync
index 620557c..8ae8758 100755
--- a/bin/mailsync
+++ b/bin/mailsync
@@ -1,6 +1,9 @@
#!/usr/bin/env sh
# Sync mail and give notification if there is new mail.
+# Run only if user logged in (prevent cron errors)
+w | grep "^$USER\W" >/dev/null || exit
+
# Checks for internet connection and set notification script.
ping -q -c 1 1.1.1.1 > /dev/null || exit
command -v notify-send >/dev/null || echo "Note that \`libnotify\` or \`libnotify-send\` should be installed for pop-up mail notifications with this script."
@@ -18,7 +21,12 @@ echo " 🔃" > /tmp/imapsyncicon_$USER
pkill -RTMIN+12 i3blocks
# Run mbsync. You can feed this script different settings.
-mbsync -a "$@"
+if [ $# -eq 0 ]; then
+ mbsync -a
+else
+ mbsync "$@"
+fi
+
rm -f /tmp/imapsyncicon_$USER
pkill -RTMIN+12 i3blocks