AutoYADM commit: 2025-03-17 23:00:06
This commit is contained in:
parent
0b9d4c2a68
commit
f5b3ffcde5
11 changed files with 42 additions and 45 deletions
|
@ -1,52 +1,47 @@
|
|||
#!/bin/env bash
|
||||
|
||||
# mailboxes to monitor
|
||||
MAILBOXES=("personal" "school")
|
||||
# named pipe for receiving refresh events
|
||||
# from mail sync script
|
||||
PIPE="/tmp/email_refresh_pipe"
|
||||
COUNT="/tmp/email_count"
|
||||
# COUNT="/tmp/email_count"
|
||||
|
||||
# Create pipe if doesn't exist
|
||||
[[ -p "$PIPE" ]] || mkfifo "$PIPE"
|
||||
|
||||
if [ ! -e "$COUNT" ]; then
|
||||
echo "0" > "$COUNT"
|
||||
fi
|
||||
# if [ ! -e "$COUNT" ]; then
|
||||
# echo "0" > "$COUNT"
|
||||
# fi
|
||||
|
||||
# mailboxes to monitor
|
||||
MAILBOXES=("personal" "school")
|
||||
# Get unread counts and format for waybar
|
||||
get_unread_counts() {
|
||||
for mailbox in "${MAILBOXES[@]}"; do
|
||||
count=$(notmuch count --output=messages "tag:unread and path:$mailbox/**")
|
||||
printf "%s: %s " "$mailbox" "$count"
|
||||
done
|
||||
# we print a newline to let waybar know to display
|
||||
# what we just printed
|
||||
printf "|\n"
|
||||
for mailbox in "${MAILBOXES[@]}"; do
|
||||
count=$(notmuch count --output=messages "tag:unread and path:$mailbox/**")
|
||||
printf "%s: %s " "$mailbox" "$count"
|
||||
done
|
||||
# we print a newline to let waybar know to display
|
||||
# what we just printed
|
||||
printf "|\n"
|
||||
}
|
||||
|
||||
|
||||
# run once for initial output
|
||||
echo "mail init |"
|
||||
# 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
|
||||
PAYLOAD=$(cat /tmp/email_refresh_pipe)
|
||||
if [ "$PAYLOAD" == "add" ]; then
|
||||
count=$(cat "$COUNT")
|
||||
((count++))
|
||||
echo "$count" > "$COUNT"
|
||||
echo "new: $(cat "$COUNT") |"
|
||||
# elif [ "$PAYLOAD" == "reset" ]; then
|
||||
# "0" > "$COUNT"
|
||||
elif [ "$PAYLOAD" == "show_precise" ]; then
|
||||
echo "0" > "$COUNT"
|
||||
get_unread_counts
|
||||
elif [ "$PAYLOAD" == "show_since" ]; then
|
||||
echo "new: $(cat "$COUNT") |"
|
||||
else
|
||||
get_unread_counts
|
||||
fi
|
||||
# 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
|
||||
PAYLOAD=$(cat /tmp/email_refresh_pipe)
|
||||
if [ "$PAYLOAD" == "new" ]; then
|
||||
echo "m* |"
|
||||
# count=$(cat "$COUNT")
|
||||
# ((count++))
|
||||
# echo "$count" > "$COUNT"
|
||||
# echo "new: $(cat "$COUNT") |"
|
||||
# elif [ "$PAYLOAD" == "reset" ]; then
|
||||
# "0" > "$COUNT"
|
||||
else
|
||||
get_unread_counts
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue