AutoYADM commit: 2025-03-17 22:30:07

This commit is contained in:
Daniel Fichtinger 2025-03-17 22:30:08 -04:00
parent a910267105
commit 0e26e9f3fa
7 changed files with 27 additions and 17 deletions

View file

@ -5,9 +5,11 @@ MAILBOXES=("personal" "school")
# named pipe for receiving refresh events
# from mail sync script
PIPE="/tmp/email_refresh_pipe"
COUNT="/tmp/email_count"
# Create pipe if doesn't exist
[[ -p "$PIPE" ]] || mkfifo "$PIPE"
[[ -e "$COUNT" ]] || echo "0" > "$COUNT"
# Get unread counts and format for waybar
get_unread_counts() {
@ -22,13 +24,21 @@ get_unread_counts() {
# run once for initial output
get_unread_counts
echo "mail init"
# begin event loop
while true; do
# cat blocks until data comes through pipe
# redirecting to null b.c. we don't want the
# pipe's contents to be printed to stdout
cat /tmp/email_refresh_pipe > /dev/null
# print unread indicator to stdout
get_unread_counts
PAYLOAD=$(cat /tmp/email_refresh_pipe)
if [ "$PAYLOAD" == "new" ]; then
count=$(cat "$COUNT")
((count++)) > "$COUNT"
elif [ "$PAYLOAD" == "reset" ]; then
"0" > "$COUNT"
elif [ "$PAYLOAD" == "show_precise" ]; then
get_unread_counts
elif [ "$PAYLOAD" == "show_since" ]; then
echo "new: $(cat "$COUNT")"
fi
done

View file

@ -1,4 +1,4 @@
#!/bin/env bash
notify-send "New mail in $1 inbox!"
/home/fic/.config/mail/mail-sync.sh
# /home/fic/.config/mail/mail-sync.sh