mutt-wizard

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit bce80d2bfcb3ef1b2707e4f256eb82212ce1022f
parent b7b7f21d692048f34287615312ebc9385cd3c378
Author: awy <awy@awy.one>
Date:   Thu, 24 Apr 2025 21:15:12 +0300

added dbus variable for dinit, fixed notifications on wayland, make it so mailsync updates swaybar mail count indicator

Diffstat:
Mbin/mailsync | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 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"