From 343fa4e9c65afab617959fda4d7bd97061162d00 Mon Sep 17 00:00:00 2001 From: Felix Van der Jeugt Date: Mon, 8 May 2017 14:06:59 +0200 Subject: [PATCH] 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). --- local/bin/src2img | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 local/bin/src2img diff --git a/local/bin/src2img b/local/bin/src2img new file mode 100755 index 0000000..119203e --- /dev/null +++ b/local/bin/src2img @@ -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" +