feat(prog/xmobar): add unread email count

This commit is contained in:
Dmitriy Pleshevskiy 2022-04-25 22:54:05 +03:00
parent cb049322d8
commit 45f68a9c76
2 changed files with 14 additions and 4 deletions

View file

@ -52,7 +52,7 @@ config n = defaultConfig
, alignSep = "}{" , alignSep = "}{"
, template = "%XMonadLog%" , template = "%XMonadLog%"
<> "} %date% <hspace=60/> %cpu% | %memory% * %swap% | %wlxd03745e1e87bwi%" <> "} %date% <hspace=60/> %cpu% | %memory% * %swap% | %wlxd03745e1e87bwi%"
<> "{ Vol: %volume% <fn=1><box> %kbd% </box> <fc=#ee9a00>%time%</fc></fn>" <> "{ Emails: %emails% <hspace=8/> Vol: %volume% <fn=1><box> %kbd% </box> <fc=#ee9a00>%time%</fc></fn>"
} }
myCommands :: [Runnable] myCommands :: [Runnable]
@ -86,6 +86,7 @@ myCommands =
] ]
(10 `seconds`) (10 `seconds`)
, Run $ Com "/bin/bash" ["-c", "~/.config/xmobar/scripts/get_volume.sh"] "volume" 1 , 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 , Run XMonadLog
] ]
where where

View file

@ -1,22 +1,31 @@
#!/bin/bash #!/bin/bash
bin=~/repos/himalaya/target/release
case $1 in case $1 in
"" | "list") "" | "list")
bin=~/repos/himalaya/target/release
for acc in $(NO_COLOR=1 $bin/himalaya accounts | grep imap | awk '{ print $1 }') for acc in $(NO_COLOR=1 $bin/himalaya accounts | grep imap | awk '{ print $1 }')
do do
echo "account: $acc" echo "account: $acc"
$bin/himalaya -a "$acc" list $bin/himalaya -a "$acc" list -w 120 | grep '✷'
echo "---" echo "---"
done 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") "watch")
while true while true
do do
printf '\033[2J' printf '\033[2J'
$0 list $0 list
sleep 10 sleep 60
done done
;; ;;
esac esac