aerc: Init

This commit is contained in:
Simon Bruder 2022-06-16 19:00:34 +02:00
parent d854fe3ac8
commit c1794d2f78
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
4 changed files with 427 additions and 0 deletions

View file

@ -10,6 +10,7 @@
./gtk.nix
./htop.nix
./logitech.nix
./mail
./makemkv.nix
./misc.nix
./mpd.nix

View file

@ -0,0 +1,143 @@
#!/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
}

View file

@ -0,0 +1,278 @@
{ lib, pkgs, ... }:
let
package = pkgs.aerc;
accountDefaults = {
smtp-starttls = "yes";
copy-to = "Sent";
signature-file = pkgs.writeText "signature" ''
--
Simon Bruder
Wallmersbach 42
97215 Uffenheim
🔑 (GPG): 47E7 559E 037A 3565 2DBB F8AA 8D3C 82F9 F309 F8EC
📧 (E-Mail): simon@sbruder.de
📱 (mobile): +49 152 56561414
'';
pgp-auto-sign = true;
pgp-key-id = "47E7559E037A35652DBBF8AA8D3C82F9F309F8EC";
pgp-opportunistic-encrypt = true;
};
in
{
home.packages = [
package
];
xdg.configFile = {
"aerc/accounts.conf".text = lib.generators.toINI { } {
Personal = accountDefaults // {
source = "`imap://simon%40sbruder.de@vueko.sbruder.de`";
source-cred-cmd = "`pass sbruder.de/mail`";
outgoing = "`smtp+plain://simon%40sbruder.de@vueko.sbruder.de`";
outgoing-cred-cmd = "`pass sbruder.de/mail`";
from = "Simon Bruder <simon@sbruder.de>";
};
Riseup = accountDefaults // {
source = "`imap://sbruder@mail.riseup.net`";
source-cred-cmd = "`pass web/riseup.net | head -n 1`";
outgoing = "`smtp+plain://sbruder@mail.riseup.net`";
outgoing-cred-cmd = "`pass web/riseup.net | head -n 1`";
from = "Simon Bruder <sbruder@riseup.net>";
};
};
"aerc/aerc.conf".text = lib.generators.toINI { } {
general = {
pgp-provider = "gpg"; # internal does not work
# Allow world-readable accounts.conf (passwords are not stored in it, so it is ok)
unsafe-accounts-conf = true;
};
ui = {
index-format = "%-17.17D %-20.20n %Z %s";
# See https://godoc.org/time#Time.Format
timestamp-format = "2006-01-02 15:04 MST";
this-day-time-format = "15:04";
this-week-time-format = "Monday 15:04";
this-year-time-format = "02 January";
pinned-tab-marker = "";
border-char-vertical = "";
border-char-horizontal = "";
fuzzy-complete = true;
threading-enabled = true;
new-message-bell = false;
};
statusline = {
display-mode = "icon";
};
viewer = {
header-layout = lib.concatStringsSep "," [
"From|To"
"Cc|Bcc"
"Subject"
"Date"
"Reply-To"
"X-Mailer"
"User-Agent"
];
};
compose = {
editor = "nvim";
header-layout = lib.concatStringsSep "," [
"To|From"
"Subject"
];
address-book-cmd = "khard email --parsable --remove-first-line %s";
};
filters = {
"subject,~^\\[PATCH" = "awk -f ${package}/share/aerc/filters/hldiff";
"text/plain" = "${./colorize}"; # taken from upstream and patched
"text/html" = "html"; # internal filter
"text/calendar" = "${pkgs.python3.withPackages (ps: with ps; [ vobject ])}/bin/python ${package}/share/aerc/filters/show-ics-details.py"; # hacky fix for broken nix support
};
triggers = {
new-email = "exec notify-send -i mail-unread-symbolic 'New e-mail from %n' '%s'";
};
templates = { };
};
"aerc/binds.conf".text = lib.generators.toINIWithGlobalSection { } {
globalSection = {
# Binds are of the form <key sequence> = <command to run>
# To use '=' in a key sequence, substitute it with "Eq": "<Ctrl+Eq>"
# If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab<Enter>";
"<C-t>" = ":term<Enter>";
};
sections = {
messages = {
"q" = ":quit<Enter>";
"j" = ":next<Enter>";
"<Down>" = ":next<Enter>";
"<C-d>" = ":next 50%<Enter>";
"<C-f>" = ":next 100%<Enter>";
"<PgDn>" = ":next 100%<Enter>";
"k" = ":prev<Enter>";
"<Up>" = ":prev<Enter>";
"<C-u>" = ":prev 50%<Enter>";
"<C-b>" = ":prev 100%<Enter>";
"<PgUp>" = ":prev 100%<Enter>";
"g" = ":select 0<Enter>";
"G" = ":select -1<Enter>";
"J" = ":next-folder<Enter>";
"K" = ":prev-folder<Enter>";
"H" = ":collapse-folder<Enter>";
"L" = ":expand-folder<Enter>";
"v" = ":mark -t<Enter>";
"V" = ":mark -v<Enter>";
"T" = ":toggle-threads<Enter>";
"<Enter>" = ":view<Enter>";
"d" = ":prompt 'Really delete this message?' 'delete-message'<Enter>";
"D" = ":delete<Enter>";
"A" = ":archive flat<Enter>";
"C" = ":compose<Enter>";
"rr" = ":reply -a<Enter>";
"rq" = ":reply -aq<Enter>";
"Rr" = ":reply<Enter>";
"Rq" = ":reply -q<Enter>";
"c" = ":cf<space>";
"$" = ":term<space>";
"!" = ":term<space>";
"|" = ":pipe<space>";
"/" = ":search<space>";
"\\" = ":filter<space>";
"n" = ":next-result<Enter>";
"N" = ":prev-result<Enter>";
"<Esc>" = ":clear<Enter>";
};
view = {
"/" = ":toggle-key-passthrough<Enter>/";
"q" = ":close<Enter>";
"O" = ":open<Enter>";
"S" = ":save<space>";
"|" = ":pipe<space>";
"D" = ":delete<Enter>";
"A" = ":archive flat<Enter>";
"f" = ":forward<Enter>";
"rr" = ":reply -a<Enter>";
"rq" = ":reply -aq<Enter>";
"Rr" = ":reply<Enter>";
"Rq" = ":reply -q<Enter>";
"H" = ":toggle-headers<Enter>";
"<C-k>" = ":prev-part<Enter>";
"<C-j>" = ":next-part<Enter>";
"J" = ":next<Enter>";
"K" = ":prev<Enter>";
};
"view::passthrough" = {
"$noinherit" = "true";
"$ex" = "<C-x>";
"<Esc>" = ":toggle-key-passthrough<Enter>";
};
# Keybindings used when the embedded terminal is not selected in the compose view"
compose = {
"$ex" = "<C-x>";
"<C-k>" = ":prev-field<Enter>";
"<C-j>" = ":next-field<Enter>";
"<tab>" = ":next-field<Enter>";
"<backtab>" = ":prev-field<Enter>";
};
# Keybindings used when the embedded terminal is selected in the compose view
"compose::editor" = {
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-k>" = ":prev-field<Enter>";
"<C-j>" = ":next-field<Enter>";
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab<Enter>";
};
# Keybindings used when reviewing a message to be sent
"compose::review" = {
"y" = ":send<Enter>";
"n" = ":abort<Enter>";
"p" = ":postpone<Enter>";
"q" = ":choose -o d discard abort -o p postpone postpone<Enter>";
"e" = ":edit<Enter>";
"a" = ":attach<space>";
"d" = ":detach<space>";
};
terminal = {
"$noinherit" = "true";
"$ex" = "<C-x>";
"<C-p>" = ":prev-tab<Enter>";
"<C-n>" = ":next-tab<Enter>";
};
};
};
"aerc/stylesets/default".text = lib.concatStrings
(lib.mapAttrsToList
(k: v: "${k} = ${if lib.isBool v then (if v then "true" else "false") else toString v}\n")
{
"*.selected.reverse" = true;
"title.reverse" = true;
"header.bold" = true;
"*error.bold" = true;
"error.fg" = 1;
"warning.fg" = 3;
"success.fg" = 2;
"statusline_default.bg" = 0;
"statusline_error.fg" = 1;
"statusline_error.reverse" = true;
"statusline_success.fg" = 2;
"statusline_success.reverse" = true;
"msglist_unread.bold" = true;
"msglist_deleted.fg" = 10;
"tab.bg" = 11;
"tab.selected.reverse" = false;
"tab.selected.bg" = 12;
"tab.fg" = 0;
"completion_default.bg" = 0;
});
};
}

View file

@ -0,0 +1,5 @@
{
imports = [
./aerc
];
}