diff options
author | awy <awy@awy.one> | 2025-07-29 03:42:18 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-07-29 03:42:18 +0300 |
commit | ef6dff4cce15186a66ba34cdd7bd39958ebf7f58 (patch) | |
tree | fcfa61164ca6e79c900b5d11f6afc6b46aaccb84 /.local/bin/statusbar/sb-mailbox | |
download | hyprdots-ef6dff4cce15186a66ba34cdd7bd39958ebf7f58.tar.gz |
first commit
Diffstat (limited to '.local/bin/statusbar/sb-mailbox')
-rwxr-xr-x | .local/bin/statusbar/sb-mailbox | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/.local/bin/statusbar/sb-mailbox b/.local/bin/statusbar/sb-mailbox new file mode 100755 index 0000000..13ded2b --- /dev/null +++ b/.local/bin/statusbar/sb-mailbox @@ -0,0 +1,24 @@ +#!/bin/sh + +# Displays number of unread mail and an loading icon if updating. +# When clicked, brings up `neomutt`. + +case $BLOCK_BUTTON in + 1) setsid -w -f "$TERMINAL" -e neomutt ; pkill -RTMIN+12 "${STATUSBAR:-waybar}" ;; + 2) setsid -f mailup >/dev/null && exit ;; + 3) notify-send "📬 Mail module" "\- Shows unread mail +- Shows 🔃 if syncing mail +- Left click opens neomutt +- Middle click syncs mail" ;; + 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" >/dev/null 2>&1 ;; +esac + +unread="$(fd . "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/ -t f | wc -l 2>/dev/null)" + +icon=$(bat /tmp/mailupdate 2>/dev/null) + +if [ "$unread" -eq 0 ]; then + [ -n "$icon" ] && echo "📬$icon" || exit 0 +else + echo "📬$unread$icon" +fi |