mirror of
https://github.com/kmein/niveum
synced 2026-03-19 11:31:09 +01:00
feat(i3status-rust): make email state depend on which account the unseen messages are
This commit is contained in:
@@ -106,27 +106,30 @@ in {
|
|||||||
'
|
'
|
||||||
'';
|
'';
|
||||||
json = true;
|
json = true;
|
||||||
|
hide_when_empty = true;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
block = "custom";
|
block = "custom";
|
||||||
interval = 60 * 5;
|
interval = 60 * 5;
|
||||||
command = let
|
command = let
|
||||||
query-account = account:
|
query-account = name: account:
|
||||||
pkgs.writers.writeDash "query-imap" ''
|
pkgs.writers.writeDash "query-imap-${name}" ''
|
||||||
${pkgs.curl}/bin/curl -sSL -u ${lib.escapeShellArg "${account.user}:${account.password}"} imaps://${account.imap} -X 'STATUS INBOX (UNSEEN)' \
|
${pkgs.curl}/bin/curl -sSL -u ${lib.escapeShellArg "${account.user}:${account.password}"} imaps://${account.imap} -X 'STATUS INBOX (UNSEEN)' \
|
||||||
| ${pkgs.gnugrep}/bin/grep -Eo '[0-9]+'
|
| ${pkgs.gnugrep}/bin/grep -Eo '[0-9]+' \
|
||||||
|
| sed 's/^/{"${name}":/;s/$/}/'
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
pkgs.writers.writeDash "unread-mail" ''
|
pkgs.writers.writeDash "unread-mail" ''
|
||||||
{
|
{
|
||||||
${lib.concatMapStringsSep "\n" query-account (builtins.attrValues accounts)}
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList query-account accounts)}
|
||||||
} | jq -s '
|
} | jq -s '
|
||||||
(. | add) as $sum
|
add
|
||||||
|
| (values | add) as $sum
|
||||||
| {
|
| {
|
||||||
text: $sum | tostring,
|
text: (if $sum > 0 then $sum | tostring else "" end),
|
||||||
icon: "mail",
|
icon: "mail",
|
||||||
state: (
|
state: (
|
||||||
if $sum > 5 then
|
if .uni > 0 or .["work-uni"] > 0 or .posteo > 0 then
|
||||||
"Warning"
|
"Warning"
|
||||||
elif $sum > 0 then
|
elif $sum > 0 then
|
||||||
"Info"
|
"Info"
|
||||||
|
|||||||
Reference in New Issue
Block a user