~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 4

[PATCH] wiki: adds some instructions for printing emails

Details
Message ID
<20221011181050.3187711-1-ser@ser1.net>
DKIM signature
missing
Download raw message
Patch: +74 -0
---
 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
Moritz Poldrack <moritz@poldrack.me>
Details
Message ID
<73db0adc-5e96-45c4-a476-8013d198f2d1@poldrack.me>
In-Reply-To
<20221011181050.3187711-1-ser@ser1.net> (view parent)
DKIM signature
missing
Download raw message
Just curious: is there an advantage over :pipe lpr?
Details
Message ID
<CNJCW8WJT9LE.1J95E2DL9J5PE@glamdring>
In-Reply-To
<73db0adc-5e96-45c4-a476-8013d198f2d1@poldrack.me> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<CNN5ILJYSXJO.1OZEUOHPUONE9@hades.moritz.sh>
In-Reply-To
<CNJCW8WJT9LE.1J95E2DL9J5PE@glamdring> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<CNN8D0UDJIB9.1KUMMFLE5HTUZ@marty>
In-Reply-To
<20221011181050.3187711-1-ser@ser1.net> (view parent)
DKIM signature
missing
Download raw message
I reformatted the text (wrapped lines) and added continuation markers
for the :choose command.

https://git.sr.ht/~rjarry/aerc/commit/bd28ba3032ffd67ea4ecca9e84feed22a2f02767
https://man.sr.ht/~rjarry/aerc/integrations/printing.md

Applied. Thanks!
Reply to thread Export thread (mbox)