summaryrefslogtreecommitdiffstats
path: root/.local/bin/mailsync
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/mailsync')
-rwxr-xr-x.local/bin/mailsync18
1 files changed, 11 insertions, 7 deletions
diff --git a/.local/bin/mailsync b/.local/bin/mailsync
index cc7010b..abb4c18 100755
--- a/.local/bin/mailsync
+++ b/.local/bin/mailsync
@@ -27,7 +27,14 @@ command -v notify-send > /dev/null || echo 'Note that `libnotify` or `libnotify-
27 27
28# Required to display notifications if run as a cronjob: 28# Required to display notifications if run as a cronjob:
29export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus 29export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
30export DISPLAY=:0.0 30
31SESH=$(loginctl show-session $(awk '/tty/ {print $1}' <(loginctl)) -p Type | awk -F= '{print $2}')
32
33if [[ "$SESH" = "wayland" ]]; then
34 export WAYLAND_DISPLAY=wayland-1
35else
36 export DISPLAY=:0.0
37fi
31 38
32# For individual configurations: 39# For individual configurations:
33[ -d "$HOME/.local/share/password-store" ] && export PASSWORD_STORE_DIR="$HOME/.local/share/password-store" 40[ -d "$HOME/.local/share/password-store" ] && export PASSWORD_STORE_DIR="$HOME/.local/share/password-store"
@@ -37,8 +44,8 @@ if [ "$(uname)" = "Darwin" ]; then
37 notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2; } 44 notify() { osascript -e "display notification \"$2 in $1\" with title \"You've got Mail\" subtitle \"Account: $account\"" && sleep 2; }
38 messageinfo() { osascript -e "display notification with title \"📧 $from\" subtitle \"$subject\""; } 45 messageinfo() { osascript -e "display notification with title \"📧 $from\" subtitle \"$subject\""; }
39else 46else
40 notify() { notify-send --icon="mail_new" --app-name="excerpt" "\`$1\`" "📬 $2 new mail(s)"; } 47 notify() { notify-send --icon="mail_new" --app-name="mailsync" "\`$1\`" "📬 $2 new mail(s)"; }
41 messageinfo() { notify-send --icon="mail-mark-unread" --app-name="mutt" "📧 $from" "$subject"; } 48 messageinfo() { notify-send --icon="mail-mark-unread" --app-name="mailsync" "📧 $from" "$subject"; }
42fi 49fi
43 50
44# Check account for new mail. Notify if there is new content. 51# Check account for new mail. Notify if there is new content.
@@ -60,7 +67,7 @@ syncandnotify() {
60 67
61# Sync accounts passed as argument or all. 68# Sync accounts passed as argument or all.
62if [ "$#" -eq "0" ]; then 69if [ "$#" -eq "0" ]; then
63 accounts="$(awk '/^Channel/ {print $2}' "$HOME/.mbsyncrc")" 70 accounts="$(awk '/^Channel/ {print $2}' "$HOME/.config/isyncrc")"
64else 71else
65 for arg in "$@"; do 72 for arg in "$@"; do
66 [ "${arg%${arg#?}}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1 73 [ "${arg%${arg#?}}" = '-' ] && opts="${opts:+${opts} }${arg}" && shift 1
@@ -68,15 +75,12 @@ else
68 accounts=$* 75 accounts=$*
69fi 76fi
70 77
71# ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null
72
73# Parallelize multiple accounts 78# Parallelize multiple accounts
74for account in $accounts; do 79for account in $accounts; do
75 syncandnotify & 80 syncandnotify &
76done 81done
77 82
78wait 83wait
79# ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null
80 84
81notmuch new 2> /dev/null 85notmuch new 2> /dev/null
82 86