diff options
author | awy <awy@awy.one> | 2025-04-24 21:15:12 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-04-24 21:15:12 +0300 |
commit | bce80d2bfcb3ef1b2707e4f256eb82212ce1022f (patch) | |
tree | eca92553d5b641af0008ddf04e0c67dd3c786e3c | |
parent | b7b7f21d692048f34287615312ebc9385cd3c378 (diff) |
added dbus variable for dinit, fixed notifications on wayland, make it so mailsync updates swaybar mail count indicator
-rwxr-xr-x | bin/mailsync | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/mailsync b/bin/mailsync index 3a681f0..f25722e 100755 --- a/bin/mailsync +++ b/bin/mailsync @@ -40,6 +40,7 @@ case "$(uname)" in *) case "$(readlink -f /sbin/init)" in *systemd*|*openrc*) export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus ;; + *dinit*) export DBUS_SESSION_BUS_ADDRESS=$(grep -E -z "DBUS_SESSION_BUS_ADDRESS" "/proc/$(pgrep -x swaybar)/environ" | sed 's/DBUS_SESSION_BUS_ADDRESS=//') ;; esac # remember if a display server is running since `ps` doesn't always contain a display pgrepoutput="$(pgrep -ax X\(\|org\|wayland\))" @@ -47,7 +48,7 @@ case "$(uname)" in [ -z "$displays" ] && [ -d /tmp/.X11-unix ] && displays=$(cd /tmp/.X11-unix && for x in X*; do echo ":${x#X}"; done) notify() { [ -n "$pgrepoutput" ] && for x in ${displays:-:0}; do - export DISPLAY="$x" + export DISPLAY=":0" notify-send --app-name="mutt-wizard" -- "$1" "$2" done ;} ;; @@ -66,11 +67,11 @@ syncandnotify() { newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) case 1 in $((newcount > 5)) ) - echo "$newcount new mails for $2." >/dev/tty + echo "$newcount new mails for $2." [ -z "$MAILSYNC_MUTE" ] && notify "New Mail!" "📬 $newcount new mails in \`$2\` account." ;; $((newcount > 0)) ) - echo "$newcount new mail(s) for $2." >/dev/tty + echo "$newcount new mail(s) for $2." [ -z "$MAILSYNC_MUTE" ] && for file in $new; do # Extract and decode subject and sender from mail. @@ -112,5 +113,6 @@ wait notmuch new --quiet +pkill -RTMIN+12 "${STATUSBAR:-i3blocks}" #Create a touch file that indicates the time of the last run of mailsync touch "$lastrun" |