diff options
Diffstat (limited to '.local/bin/mailsync')
-rwxr-xr-x | .local/bin/mailsync | 18 |
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: |
29 | export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus | 29 | export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus |
30 | export DISPLAY=:0.0 | 30 | |
31 | SESH=$(loginctl show-session $(awk '/tty/ {print $1}' <(loginctl)) -p Type | awk -F= '{print $2}') | ||
32 | |||
33 | if [[ "$SESH" = "wayland" ]]; then | ||
34 | export WAYLAND_DISPLAY=wayland-1 | ||
35 | else | ||
36 | export DISPLAY=:0.0 | ||
37 | fi | ||
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\""; } |
39 | else | 46 | else |
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"; } |
42 | fi | 49 | fi |
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. |
62 | if [ "$#" -eq "0" ]; then | 69 | if [ "$#" -eq "0" ]; then |
63 | accounts="$(awk '/^Channel/ {print $2}' "$HOME/.mbsyncrc")" | 70 | accounts="$(awk '/^Channel/ {print $2}' "$HOME/.config/isyncrc")" |
64 | else | 71 | else |
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=$* |
69 | fi | 76 | fi |
70 | 77 | ||
71 | # ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null | ||
72 | |||
73 | # Parallelize multiple accounts | 78 | # Parallelize multiple accounts |
74 | for account in $accounts; do | 79 | for account in $accounts; do |
75 | syncandnotify & | 80 | syncandnotify & |
76 | done | 81 | done |
77 | 82 | ||
78 | wait | 83 | wait |
79 | # ( kill -46 "$(pidof "${STATUSBAR:-dwmblocks}")" >/dev/null 2>&1 ) 2>/dev/null | ||
80 | 84 | ||
81 | notmuch new 2> /dev/null | 85 | notmuch new 2> /dev/null |
82 | 86 | ||