diff --git a/configs/neomutt.nix b/configs/neomutt.nix index f426b64..6969f9d 100644 --- a/configs/neomutt.nix +++ b/configs/neomutt.nix @@ -5,131 +5,7 @@ }: let mainMailbox = "posteo"; - accounts.uni = { - user = "meinhark"; - password = lib.strings.fileContents ; - address = "kieran.felix.meinhardt@hu-berlin.de"; - imap = "mailbox.cms.hu-berlin.de"; - smtp = "mailhost.cms.hu-berlin.de"; - smtpSettings = smtp: "smtp://${smtp}"; - folders = { - drafts = "Drafts"; - sent = "Sent"; - trash = "Trash"; - }; - }; - - accounts.uni-old = { - user = "meinhark"; - password = lib.strings.fileContents ; - address = "meinhark@informatik.hu-berlin.de"; - imap = "mailbox.informatik.hu-berlin.de"; - smtp = "mailhost.informatik.hu-berlin.de"; - smtpSettings = smtp: "smtp://${smtp}"; - folders = { - drafts = "Drafts"; - sent = "Sent"; - trash = "Trash"; - }; - }; - - accounts.work-uni = { - user = "meinhaki"; - password = lib.strings.fileContents ; - address = "kieran.meinhardt@hu-berlin.de"; - imap = "mailbox.cms.hu-berlin.de"; - smtp = "mailhost.cms.hu-berlin.de"; - smtpSettings = smtp: "smtp://${smtp}"; - folders = { - drafts = "Drafts"; - sent = "Sent"; - trash = "Trash"; - }; - }; - - accounts.work-admin = { - user = "dslalewa"; - password = lib.strings.fileContents ; - address = "admin.alew.vglsprwi@hu-berlin.de"; - imap = "mailbox.cms.hu-berlin.de"; - smtp = "mailhost.cms.hu-berlin.de"; - smtpSettings = smtp: "smtp://${smtp}"; - folders = { - drafts = "Drafts"; - sent = "Sent"; - trash = "Trash"; - }; - }; - - accounts.work-fysi = rec { - user = "kieran@fysi.tech"; - address = user; - password = lib.strings.fileContents ; - imap = "imap.fastmail.com"; - smtp = "smtp.fastmail.com"; - smtpSettings = smtp: "smtps://${smtp}:465"; - folders = { - drafts = "Drafts"; - sent = "Sent"; - trash = "Trash"; - }; - }; - - accounts.cock = rec { - user = "2210@cock.li"; - address = user; - password = lib.strings.fileContents ; - imap = "mail.cock.li"; - smtp = imap; - smtpSettings = smtp: "smtp://${smtp}:587"; - folders = { - drafts = "Drafts"; - sent = "Sent"; - trash = "Trash"; - }; - }; - - accounts."${mainMailbox}" = rec { - user = "kieran.meinhardt@posteo.net"; - address = user; - password = lib.strings.fileContents ; - imap = "posteo.de"; - smtp = imap; - smtpSettings = smtp: "smtp://${smtp}"; - folders = { - drafts = "Drafts"; - sent = "Sent"; - trash = "Trash"; - }; - }; - - accounts.google-amro = rec { - user = "amroplay@gmail.com"; - address = user; - password = lib.strings.fileContents ; - imap = "imap.gmail.com"; - smtp = "smtp.gmail.com"; - smtpSettings = smtp: "smtps://${smtp}:465"; - folders = { - drafts = "[Gmail]/Drafts"; - sent = "[Gmail]/Sent Mail"; - trash = "[Gmail]/Bin"; - }; - }; - - accounts.google-kieran = rec { - user = "kieran.meinhardt@gmail.com"; - address = user; - password = lib.strings.fileContents ; - imap = "imap.gmail.com"; - smtp = "smtp.gmail.com"; - smtpSettings = smtp: "smtps://${smtp}:465"; - folders = { - drafts = "[Gmail]/Entwürfe"; - sent = "[Gmail]/Gesendet"; - trash = "[Gmail]/Papierkorb"; - }; - }; + accounts = import {inherit lib mainMailbox;}; in { environment.systemPackages = [pkgs.neomutt]; environment.shellAliases.mua = "${pkgs.neomutt}/bin/neomutt -f ${mainMailbox}←"; diff --git a/configs/newsboat.nix b/configs/newsboat.nix index fd18ab6..b2aa6da 100644 --- a/configs/newsboat.nix +++ b/configs/newsboat.nix @@ -84,7 +84,7 @@ in { '{ state: (if $unread > 0 then "Good" else "Idle" end), text: "\($unread) [\($watchLater)]", - icon: "mail" + icon: "rss" }' fi '') diff --git a/lib/email.nix b/lib/email.nix new file mode 100644 index 0000000..7f3d405 --- /dev/null +++ b/lib/email.nix @@ -0,0 +1,131 @@ +{ + lib, + mainMailbox ? "posteo", + ... +}: { + uni = { + user = "meinhark"; + password = lib.strings.fileContents ; + address = "kieran.felix.meinhardt@hu-berlin.de"; + imap = "mailbox.cms.hu-berlin.de"; + smtp = "mailhost.cms.hu-berlin.de"; + smtpSettings = smtp: "smtp://${smtp}"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + uni-old = { + user = "meinhark"; + password = lib.strings.fileContents ; + address = "meinhark@informatik.hu-berlin.de"; + imap = "mailbox.informatik.hu-berlin.de"; + smtp = "mailhost.informatik.hu-berlin.de"; + smtpSettings = smtp: "smtp://${smtp}"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + work-uni = { + user = "meinhaki"; + password = lib.strings.fileContents ; + address = "kieran.meinhardt@hu-berlin.de"; + imap = "mailbox.cms.hu-berlin.de"; + smtp = "mailhost.cms.hu-berlin.de"; + smtpSettings = smtp: "smtp://${smtp}"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + work-admin = { + user = "dslalewa"; + password = lib.strings.fileContents ; + address = "admin.alew.vglsprwi@hu-berlin.de"; + imap = "mailbox.cms.hu-berlin.de"; + smtp = "mailhost.cms.hu-berlin.de"; + smtpSettings = smtp: "smtp://${smtp}"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + work-fysi = rec { + user = "kieran@fysi.tech"; + address = user; + password = lib.strings.fileContents ; + imap = "imap.fastmail.com"; + smtp = "smtp.fastmail.com"; + smtpSettings = smtp: "smtps://${smtp}:465"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + cock = rec { + user = "2210@cock.li"; + address = user; + password = lib.strings.fileContents ; + imap = "mail.cock.li"; + smtp = imap; + smtpSettings = smtp: "smtp://${smtp}:587"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + "${mainMailbox}" = rec { + user = "kieran.meinhardt@posteo.net"; + address = user; + password = lib.strings.fileContents ; + imap = "posteo.de"; + smtp = imap; + smtpSettings = smtp: "smtp://${smtp}"; + folders = { + drafts = "Drafts"; + sent = "Sent"; + trash = "Trash"; + }; + }; + + google-amro = rec { + user = "amroplay@gmail.com"; + address = user; + password = lib.strings.fileContents ; + imap = "imap.gmail.com"; + smtp = "smtp.gmail.com"; + smtpSettings = smtp: "smtps://${smtp}:465"; + folders = { + drafts = "[Gmail]/Drafts"; + sent = "[Gmail]/Sent Mail"; + trash = "[Gmail]/Bin"; + }; + }; + + google-kieran = rec { + user = "kieran.meinhardt@gmail.com"; + address = user; + password = lib.strings.fileContents ; + imap = "imap.gmail.com"; + smtp = "smtp.gmail.com"; + smtpSettings = smtp: "smtps://${smtp}:465"; + folders = { + drafts = "[Gmail]/Entwürfe"; + sent = "[Gmail]/Gesendet"; + trash = "[Gmail]/Papierkorb"; + }; + }; +} diff --git a/lib/i3status-rust.nix b/lib/i3status-rust.nix index 0c16d89..ac797b9 100644 --- a/lib/i3status-rust.nix +++ b/lib/i3status-rust.nix @@ -10,6 +10,8 @@ pkgs.writers.writeDash "setsid-command" '' ${pkgs.utillinux}/bin/setsid ${script} ''; + + accounts = import {inherit lib;}; in { theme = { name = "plain"; @@ -32,6 +34,7 @@ in { }; }; icons.name = "awesome6"; + icons.overrides.rss = ""; block = [ { block = "weather"; @@ -98,6 +101,37 @@ in { ''; json = true; } + { + block = "custom"; + interval = 60 * 5; + command = let + query-account = account: + pkgs.writers.writeDash "query-imap" '' + ${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]+' + ''; + in + pkgs.writers.writeDash "unread-mail" '' + { + ${query-account accounts.posteo} + ${query-account accounts.uni} + } | jq -s '{ + text: . | map(tostring) | join("+"), + icon: "mail", + state: ( + (. | add) as $sum + | if $sum > 5 then + "Warning" + elif $sum > 0 then + "Info" + else + "Idle" + end + ) + }' + ''; + json = true; + } { block = "custom"; interval = 5;