diff options
author | Luke Smith <luke@lukesmith.xyz> | 2019-07-24 15:27:22 -0400 |
---|---|---|
committer | Luke Smith <luke@lukesmith.xyz> | 2019-07-24 15:27:22 -0400 |
commit | c270bdb5df7593128e707348baee4697bbe20ee2 (patch) | |
tree | e12aedc52157e0264f6b5b47c9664ed68972fba3 /bin/mailsync | |
parent | 35a6ce1e66b607f4b61ab553b83799213f2a4a73 (diff) |
vars in script; msg if fail
Diffstat (limited to 'bin/mailsync')
-rwxr-xr-x | bin/mailsync | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/bin/mailsync b/bin/mailsync index 202d9be..d79507d 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -1,17 +1,20 @@ #!/usr/bin/env sh # Sync mail and give notification if there is new mail. +export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus +export DISPLAY=:0.0 +[ -d "$HOME/.local/share/password-store" ] && export PASSWORD_STORE_DIR="$HOME/.local/share/password-store" + # Run only if user logged in (prevent cron errors) -pgrep -u "$USER" >/dev/null || exit +pgrep -u "$USER" >/dev/null || { echo "$USER not logged in; sync will not run."; exit ;} # Run only if not already running in other instance -pgrep -x mbsync >/dev/null && exit +pgrep -x mbsync >/dev/null && { echo "mbsync is already running." ; exit ;} # Checks for internet connection and set notification script. -ping -q -c 1 1.1.1.1 > /dev/null || exit +ping -q -c 1 1.1.1.1 > /dev/null || { echo "No internet connection detected."; 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." -export DISPLAY=:0.0 - # Settings are different for MacOS (Darwin) systems. if [ "$(uname)" = "Darwin" ]; then notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2 ;} |