Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

TuxPaint use cups print dialog

I was finally ready to print something from TuxPaint, and this appears to be lacking current attention. I was unable to find useful guidance on the www, so I devised my own plan.

Tuxpaint can be configured to run an arbitrary command, and it will pipe postscript to its standard input.

Screenshot of tuxpaint-config

With that in mind, I set this script up.

files/2025/listings/tuxpaint-print.sh (Source)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#!/bin/sh
# Startdate: 2025-08-03-1 15:08
# Dependencies: cupsfilter, xdotool, atril
LOGFILE=~/log/tpp.$( date "+%FT%H%M%S" ).log
exec 1>>"${LOGFILE}"
exec 2>>"${LOGFILE}"
tmpfile="$( mktemp )"
# must accept postscript to standard input
cat > "${tmpfile}"
echo "Got contents and dumped to tmpfile ${tmpfile}"
/usr/sbin/cupsfilter "${tmpfile}" > "${tmpfile}.2"
atril "${tmpfile}.2" &
sleep 3
xdotool key 'ctrl+p'
sleep 3
true
if test -z "${NO_CLEAN}" ; then rm -f "${tmpfile:-NOTHINGTODEL}" ; fi

Unfortunately, the xdotool keystrokes don't always get sent to Atril correctly, but at least the document is then in a regular pdf viewer that does work with a normal print dialog.

Comments