summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2022-10-11 13:10:50 -0500
committerRobin Jarry <robin@jarry.cc>2022-10-16 11:10:14 +0200
commitbd28ba3032ffd67ea4ecca9e84feed22a2f02767 (patch)
treef7445e981d48fa10d64758642ba5373756dea88d
parentbe8cae77aa5df009acdd35c2638de5b9e86c2594 (diff)
downloadaerc-bd28ba3032ffd67ea4ecca9e84feed22a2f02767.tar.gz
aerc-bd28ba3032ffd67ea4ecca9e84feed22a2f02767.zip
integrations: add instructions for printing emails
Signed-off-by: Sean E. Russell <ser@ser1.net> Signed-off-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--integrations/index.md1
-rw-r--r--integrations/printing.md75
2 files changed, 76 insertions, 0 deletions
diff --git a/integrations/index.md b/integrations/index.md
index d7badcd8..53077eb8 100644
--- a/integrations/index.md
+++ b/integrations/index.md
@@ -8,3 +8,4 @@ title: "aerc-wiki: Integrations"
- [pgp](integrations/pgp.md)
- [sourcehut](integrations/sourcehut.md)
- [translator](integrations/translator.md)
+- [printing](integrations/printing.md)
diff --git a/integrations/printing.md b/integrations/printing.md
new file mode 100644
index 00000000..34518fff
--- /dev/null
+++ b/integrations/printing.md
@@ -0,0 +1,75 @@
+---
+title: "aerc-wiki: Integrations/printing"
+---
+
+# printing
+
+You can use [email2pdf](https://github.com/andrewferrier/email2pdf) to print
+emails, and the `choose` command to select printers.
+
+First, install `email2pdf`. For example, on Arch:
+
+```sh
+yay -S email2pdf
+```
+
+Because `email2pdf` can't handle piped data, we need a little script to manage
+some temporary files. Save this script somewhere in your path; for this
+tutorial, we'll call it `emailprint`:
+
+```sh
+#!/bin/sh
+# Print a piped email
+# If an argument is provided, it is the printer name.
+# The input is an email piped over stdin.
+
+INPF="/tmp/mailprint_$$.txt"
+OPDF="/tmp/mailprint_$$.pdf"
+
+clean_temps() {
+ rm -f "$INPF" "$OPDF"
+}
+trap 'clean_temps' 0 1 2 3 15
+cat > $INPF
+
+PRINTER=""
+[[ -n $1 ]] && PRINTER="-d $1"
+
+email2pdf -i "$INPF" -o "$OPDF"
+
+if [[ $1 == "-" ]]; then
+ mv "$OPDF" "$HOME"
+ printf "Done; file is %s/%s\n" "$HOME" "$OPDF"
+else
+ lp $PRINTER "$OPDF"
+fi
+```
+
+This script takes an argument (the printer name), or a dash (`-`). The `-`,
+simply moves the intermediate PDF to your home directory, allowing you to print
+emails to PDF files. The script cleans up temporary files, and if you print to
+file, tells you where the PDF is. In aerc, this message will appear when you're
+done printing and will be dismissed when you press `<Enter>`.
+
+Make sure the script is executable (e.g., `chmod +x emailprint`).
+
+Finally, configure hotkeys in aerc to print an email, for example, in your
+`$HOME/.config/aerc/binds.conf`:
+
+```ini
+[view]
+p = :choose \
+ -o m mx "pipe -m emailprint mx" \
+ -o e epson "pipe -m emailprint epson" \
+ -o f file "pipe -m emailprint -" \
+ <Enter>
+```
+
+Make sure to replace the printer names with your printer(s). The pattern for
+each printer is:
+
+```ini
+ -o <choicekey> <choicename> "pipe -m <printscript> <printername"
+```
+
+If you have more printers, add more of the `-o` lines.