summaryrefslogtreecommitdiff
path: root/dot/local/bin/lptext
blob: 61fa3318a3e01f582b4e90d56123a7efee086ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
font=${LP_FONT:-Courier}

# Densities over 400 cause ImageMagick to cut off the top of the first line.
density=400

# Leading whitespace causes ImageMagick to duplicate the first non-empty line.
skip_leading_empty_lines()
{
    perl -pe 'if (/./) {$seen++} elsif (!$seen) {undef $_}'
}

skip_leading_empty_lines | gm convert -font $font -density $density text:- -trim png:- | lp "$@"