From b5c022c4e05d4ef6ca2b2df692c96c5f3b7269a3 Mon Sep 17 00:00:00 2001 From: janabhumi Date: Mon, 26 Sep 2022 15:12:34 +0300 Subject: [PATCH] home/email: configure aerc instead of himalaya --- home/home.nix | 4 +- home/progs/aerc.nix | 74 +++++++++++++++++++++ home/progs/colorize | 144 +++++++++++++++++++++++++++++++++++++++++ home/progs/default.nix | 1 + secrets.nix | Bin 1597 -> 1645 bytes 5 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 home/progs/aerc.nix create mode 100755 home/progs/colorize diff --git a/home/home.nix b/home/home.nix index 78543fd..1be7dd9 100644 --- a/home/home.nix +++ b/home/home.nix @@ -83,7 +83,8 @@ in pass.enable = true; # email manager - himalaya.enable = true; + himalaya.enable = false; + aerc.enable = true; # finance manager hledger.enable = true; @@ -109,6 +110,7 @@ in accounts = { email = { + maildirBasePath = "${config.xdg.dataHome}/mail"; accounts = secrets.emailAccounts; }; }; diff --git a/home/progs/aerc.nix b/home/progs/aerc.nix new file mode 100644 index 0000000..e0a91f6 --- /dev/null +++ b/home/progs/aerc.nix @@ -0,0 +1,74 @@ +{ lib, config, pkgs, ... }: + +with lib; + +let + cfg = config.progs.aerc; +in +{ + options.progs.aerc = { + enable = mkOption { + type = types.bool; + default = false; + description = "Add neomutt with my personal configuration"; + }; + }; + + # See: https://git.sbruder.de/simon/nixos-config/src/branch/master/users/simon/modules/mail/aerc/default.nix + config = mkIf cfg.enable { + programs.aerc = { + enable = true; + extraConfig = { + general.unsafe-accounts-conf = true; + + filters = { + "text/plain" = "${./colorize}"; + "text/html" = "html"; + }; + }; + extraBinds = { + messages = { + "q" = ":quit"; + + "gt" = ":next-tab"; + "gT" = ":prev-tab"; + + "j" = ":next"; + "" = ":next"; + "" = ":next 50%"; + + "k" = ":prev"; + "" = ":prev"; + "" = ":prev 50%"; + + "gg" = ":select 0"; + "G" = ":select -1"; + + "J" = ":next-folder"; + "K" = ":prev-folder"; + + "" = ":view"; + }; + + view = { + "q" = ":close"; + "O" = ":open"; + "S" = ":save"; + + "f" = ":forward"; + + "rr" = ":reply -a"; + "rq" = ":reply -aq"; + "Rr" = ":reply"; + "Rq" = ":reply -q"; + + "" = ":prev-part"; + "" = ":next-part"; + "J" = ":next"; + "K" = ":prev"; + }; + + }; + }; + }; +} diff --git a/home/progs/colorize b/home/progs/colorize new file mode 100755 index 0000000..d49e1fd --- /dev/null +++ b/home/progs/colorize @@ -0,0 +1,144 @@ +#!/usr/bin/env -S awk -f +# Copyright (c) 2022 Robin Jarry +# Modified 2022-06-16 by Simon Bruder to use ANSI colors +# Modified 2022-06-16 by Simon Bruder to a /usr/bin/env shebang + +BEGIN { + url = "\x1b[33m" # yellow + header = "\x1b[35m" # purple + signature = "\x1b[35m" # purple + diff_meta = "\x1b[1;37m" # bold white + diff_chunk = "\x1b[36m" # cyan + diff_add = "\x1b[32m" # green + diff_del = "\x1b[31m" # red + quote_1 = "\x1b[34m" # blue + quote_2 = "\x1b[91m" # orange + quote_3 = "\x1b[35m" # purple + quote_4 = "\x1b[95m" # pink + quote_x = "\x1b[37m" # gray + reset = "\x1b[0m" + # state + in_diff = 0 + in_signature = 0 + in_headers = 0 + in_body = 0 + # patterns + header_pattern = @/^[A-Z][[:alnum:]-]+:/ + url_pattern = @/[a-z]{2,6}:\/\/[[:graph:]]+|(mailto:)?[[:alnum:]_\+\.~\/-]*[[:alnum:]_]@[[:lower:]][[:alnum:]\.-]*[[:lower:]]/ +} +function color_quote(line) { + level = 0 + quotes = "" + while (line ~ /^>/) { + level += 1 + quotes = quotes ">" + line = substr(line, 2) + while (line ~ /^ /) { + quotes = quotes " " + line = substr(line, 2) + } + } + if (level == 1) { + color = quote_1 + } else if (level == 2) { + color = quote_2 + } else if (level == 3) { + color = quote_3 + } else if (level == 4) { + color = quote_4 + } else { + color = quote_x + } + if (line ~ /^\+/) { + return color quotes diff_add line reset + } else if (line ~ /^-/) { + return color quotes diff_del line reset + } + gsub(url_pattern, url "&" color, line) + return color quotes line reset +} +{ + # Strip carriage returns from line + sub(/\r$/, "") + + if (in_diff) { + if ($0 ~ /^-- ?$/) { + in_signature = 1 + in_diff = 0 + in_headers = 0 + in_body = 0 + $0 = signature $0 reset + } else if ($0 ~ /^@@ /) { + $0 = diff_chunk $0 reset + } else if ($0 ~ /^(diff --git|index|---|\+\+\+) /) { + $0 = diff_meta $0 reset + } else if ($0 ~ /^\+/) { + $0 = diff_add $0 reset + } else if ($0 ~ /^-/) { + $0 = diff_del $0 reset + } + } else if (in_signature) { + gsub(url_pattern, url "&" signature) + $0 = signature $0 reset + } else if (in_headers) { + if ($0 ~ /^$/) { + in_signature = 0 + in_diff = 0 + in_headers = 0 + in_body = 1 + } else { + sub(header_pattern, header "&" reset) + gsub(url_pattern, url "&" reset) + } + } else if (in_body) { + if ($0 ~ /^>/) { + $0 = color_quote($0) + } else if ($0 ~ /^diff --git /) { + in_signature = 0 + in_diff = 1 + in_headers = 0 + in_body = 0 + $0 = diff_meta $0 reset + } else if ($0 ~ /^-- ?$/) { + in_signature = 1 + in_diff = 0 + in_headers = 0 + in_body = 0 + $0 = signature $0 reset + } else { + gsub(url_pattern, url "&" reset) + } + } else if ($0 ~ /^diff --git /) { + in_signature = 0 + in_diff = 1 + in_headers = 0 + in_body = 0 + $0 = diff_meta $0 reset + } else if ($0 ~ /^-- ?$/) { + in_signature = 1 + in_diff = 0 + in_headers = 0 + in_body = 0 + $0 = signature $0 reset + } else if ($0 ~ header_pattern) { + in_signature = 0 + in_diff = 0 + in_headers = 1 + in_body = 0 + sub(header_pattern, header "&" reset) + gsub(url_pattern, url "&" reset) + } else { + in_signature = 0 + in_diff = 0 + in_headers = 0 + in_body = 1 + if ($0 ~ /^>/) { + $0 = color_quote($0) + } else { + gsub(url_pattern, url "&" reset) + } + } + + print +} + diff --git a/home/progs/default.nix b/home/progs/default.nix index 9f43e1f..d94da3b 100644 --- a/home/progs/default.nix +++ b/home/progs/default.nix @@ -3,6 +3,7 @@ ./exa.nix ./git.nix ./himalaya.nix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