to be used as suckless sent filter for code

Adding `{ "\\.c$", "src2img c 360" }` to the filters of sent, sent will
show highlighted code snippets. Trivially modified to work for any
language (currently C) and screen size (current resolution 360 dpi).
This commit is contained in:
Felix Van der Jeugt 2017-05-08 14:06:59 +02:00
parent 2a721c4369
commit 343fa4e9c6
No known key found for this signature in database
GPG Key ID: 58B209295023754D
1 changed files with 15 additions and 0 deletions

15
local/bin/src2img Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
srctype="$1"
dpi="$2"
tempsrc="$(mktemp --suffix=".$1")"
tempsvg="$(mktemp --suffix='.svg')"
temppng="$(mktemp --suffix='.png')"
cat > "$tempsrc"
highlight -O svg -I "$tempsrc" | grep -v 'rect' > "$tempsvg"
inkscape --without-gui --export-area-drawing --export-background-opacity=256 --export-dpi="$dpi" --export-png="$temppng" "$tempsvg" > /dev/null
png2ff < "$temppng"
rm "$tempsrc" "$tempsvg" "$temppng"