---
integrations/index.md | 1 +
integrations/printing.md | 73 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
create mode 100644 integrations/printing.md
diff --git a/integrations/index.md b/integrations/index.md
index 0e200c2..40ae800 100644
--- a/integrations/index.md
+++ b/integrations/index.md
@@ -7,3 +7,4 @@ title: "aerc-wiki: Integrations"
- [password-manager](integrations/password-manager.md)
- [pgp](integrations/pgp.md)
- [sourcehut](integrations/sourcehut.md)
+- [printing](integrations/printing.md)
diff --git a/integrations/printing.md b/integrations/printing.md
new file mode 100644
index 0000000..c90a6a2
--- /dev/null
+++ b/integrations/printing.md
@@ -0,0 +1,73 @@
+---
+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 email2pdfi. 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"
+```
+
+so, if we could break the lines, it'd look like:
+
+```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>
+```
+
+If you have more printers, add more of the `-o` lines -- just make sure the lines are all joined into one long line, or you'll get errors.
\ No newline at end of file
--
2.37.2
On Tue Oct 11, 2022 at 1:21 PM CDT, Moritz Poldrack wrote:
> Just curious: is there an advantage over :pipe lpr?
This will just dump raw text to my printer. email2pdf does some header
formatting, and it handles attachments intelligently. It prevents getting a ream
of base64 encoded pages because of a zip attachment. It handles image
attachments, and if the email has an HTML part -- or if the email is *only* an
HTML part, because it came from Outlook, email2pdf will print that nicely and
not as raw html.
Those are advantages, for me.
--- SER
Sean E. Russell
Age: age195vpft7nzsy83medxagqqsge0lrcuf9txe3z2znlu2wsk69cdu4sx8nfvp
Minisign: https://ser1.net/.well-known/minisign.pub
GPG key: https://ser1.net/.well-known/pgp.asc
Matrix: @ser:matrix.org
On Tue Oct 11, 2022 at 9:55 PM CEST, Sean E. Russell wrote:
> Those are advantages, for me.
I agree, I might use it myself next time I actually have to print an
email.
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
--
Moritz Poldrack
https://moritz.sh