From 45f68a9c7650eafc476b31017c51b5b1bafb2e95 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Mon, 25 Apr 2022 22:54:05 +0300 Subject: [PATCH] feat(prog/xmobar): add unread email count --- programs/xmonad/xmobar/src/xmobar.hs | 3 ++- scripts/him.sh | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/programs/xmonad/xmobar/src/xmobar.hs b/programs/xmonad/xmobar/src/xmobar.hs index a003ee7..30a1d5a 100644 --- a/programs/xmonad/xmobar/src/xmobar.hs +++ b/programs/xmonad/xmobar/src/xmobar.hs @@ -52,7 +52,7 @@ config n = defaultConfig , alignSep = "}{" , template = "%XMonadLog%" <> "} %date% %cpu% | %memory% * %swap% | %wlxd03745e1e87bwi%" - <> "{ Vol: %volume% %kbd% %time%" + <> "{ Emails: %emails% Vol: %volume% %kbd% %time%" } myCommands :: [Runnable] @@ -86,6 +86,7 @@ myCommands = ] (10 `seconds`) , Run $ Com "/bin/bash" ["-c", "~/.config/xmobar/scripts/get_volume.sh"] "volume" 1 + , Run $ Com "/bin/bash" ["-c", "~/scripts/him.sh unread-count"] "emails" 60 , Run XMonadLog ] where diff --git a/scripts/him.sh b/scripts/him.sh index f8fa7bc..1bdf13c 100755 --- a/scripts/him.sh +++ b/scripts/him.sh @@ -1,22 +1,31 @@ #!/bin/bash +bin=~/repos/himalaya/target/release case $1 in "" | "list") - bin=~/repos/himalaya/target/release for acc in $(NO_COLOR=1 $bin/himalaya accounts | grep imap | awk '{ print $1 }') do echo "account: $acc" - $bin/himalaya -a "$acc" list + $bin/himalaya -a "$acc" list -w 120 | grep '✷' echo "---" done ;; + "unread-count") + a=0 + for acc in $(NO_COLOR=1 $bin/himalaya accounts | grep imap | awk '{ print $1 }') + do + a=$((a+$($bin/himalaya -a "$acc" list | grep '✷' | wc -l))) + done + echo $a + ;; + "watch") while true do printf '\033[2J' $0 list - sleep 10 + sleep 60 done ;; esac