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

This commit is contained in:
Daniel Fichtinger 2025-03-17 22:45:07 -04:00
parent 0e26e9f3fa
commit ece7017d1e
5 changed files with 26 additions and 18 deletions

View file

@ -9,7 +9,10 @@ COUNT="/tmp/email_count"
# Create pipe if doesn't exist
[[ -p "$PIPE" ]] || mkfifo "$PIPE"
[[ -e "$COUNT" ]] || echo "0" > "$COUNT"
if [ ! -e "$COUNT" ]; then
echo "0" > "$COUNT"
fi
# Get unread counts and format for waybar
get_unread_counts() {
@ -24,21 +27,26 @@ get_unread_counts() {
# 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" == "new" ]; then
if [ "$PAYLOAD" == "add" ]; then
count=$(cat "$COUNT")
((count++)) > "$COUNT"
elif [ "$PAYLOAD" == "reset" ]; then
"0" > "$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")"
echo "new: $(cat "$COUNT") |"
else
get_unread_counts
fi
done