aboutsummaryrefslogtreecommitdiff
path: root/bin/print_unicode.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/print_unicode.sh')
-rwxr-xr-xbin/print_unicode.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/bin/print_unicode.sh b/bin/print_unicode.sh
new file mode 100755
index 0000000..24815a0
--- /dev/null
+++ b/bin/print_unicode.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+## print_unicode.sh
+## By Amanda Hickman https://gist.github.com/amandabee/cf7faad0a6f2afc485ee
+## Using https://github.com/baruchel/txt2pdf to print emails to PDF with unicode support.
+
+pdir="$HOME/.neomutt/tmp"
+open_pdf=qpdfview
+scriptloc="python3 $HOME/.neomutt/bin/text2pdf.py"
+
+# check to make sure that we're looking for txt2pdf in the right place
+if ! command -v python3 $scriptloc >/dev/null; then
+ echo "Is $scriptloc installed?"
+ exit 1
+fi
+
+# create temp dir if it does not exist
+if [ ! -d "$pdir" ]; then
+ mkdir -p "$pdir" 2>/dev/null
+ if [ $? -ne 0 ]; then
+ echo "Unable to make directory '$pdir'" 1>&2
+ exit 2
+ fi
+fi
+
+# dump stdin to a tempfile
+tmptxt="`mktemp $pdir/mutt_XXXXXXX.txt`"
+cat >> $tmptxt
+
+tmpfile="`mktemp $pdir/mutt_XXXXXXXX.pdf`"
+
+# Actually write the text into a PDF.
+$scriptloc --quiet -o $tmpfile $tmptxt
+$open_pdf $tmpfile >/dev/null 2>&1 &
+sleep 1
+rm $tmpfile
+rm $tmptxt