refac(nix/prog/himalaya): improve mark-read action

This commit is contained in:
Dmitriy Pleshevskiy 2022-05-11 18:23:12 +03:00
parent a3b91d1222
commit 20611ed9c6
2 changed files with 10 additions and 9 deletions

View file

@ -4,7 +4,7 @@ with lib;
let let
cfg = config.progs.himalaya; cfg = config.progs.himalaya;
bin = "${pkgs.himalaya}/bin/himalaya"; bin = "~/repos/himalaya/target/release/himalaya";
in in
{ {
options.progs.himalaya = { options.progs.himalaya = {
@ -19,7 +19,7 @@ in
programs.himalaya = { programs.himalaya = {
enable = true; enable = true;
settings = { settings = {
default-page-size = 10; default-page-size = 20;
downloads-dir = "${config.home.homeDirectory}/downloads/email"; downloads-dir = "${config.home.homeDirectory}/downloads/email";
}; };
}; };

View file

@ -1,21 +1,22 @@
#!/bin/bash #!/bin/bash
bin=~/repos/himalaya/target/release
bin=~/repos/himalaya/target/release/himalaya
case $1 in case $1 in
"" | "list") "" | "list")
for acc in $(NO_COLOR=1 $bin/himalaya accounts | grep imap | awk '{ print $1 }') for acc in $(NO_COLOR=1 $bin accounts | grep imap | awk '{ print $1 }')
do do
echo "account: $acc" echo "account: $acc"
$bin/himalaya -a "$acc" list -w 120 | grep '✷' $bin -a "$acc" list -s 10 -w 120 | grep '✷'
echo "---" echo "---"
done done
;; ;;
"unread-count") "unread-count")
a=0 a=0
for acc in $(NO_COLOR=1 $bin/himalaya accounts | grep imap | awk '{ print $1 }') for acc in $(NO_COLOR=1 $bin accounts | grep imap | awk '{ print $1 }')
do do
a=$((a+$($bin/himalaya -a "$acc" list | grep '✷' | wc -l))) a=$((a+$($bin -a "$acc" list | grep '✷' | wc -l)))
done done
echo $a echo $a
;; ;;
@ -30,9 +31,9 @@ case $1 in
;; ;;
"mark-read") "mark-read")
for id in "${@:3}" for id in $(NO_COLOR=1 $bin list -s 20 | grep '✷'| awk '{ print $1 }')
do do
$bin/himalaya -a $2 flag add $id seen $bin -a $2 flag add $id seen
done done
esac esac