commit dde8cce761996722139bac8a18aebd7e9c754f4b parent 77ff41025ad6cb576728dc16f09ded4b275fb385 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Thu, 28 May 2020 14:02:29 +0200 Add script to convert text files to pdf Diffstat:
A | .local/bin/adcast | | | 29 | +++++++++++++++++++++++++++++ |
A | .local/bin/txt2pdf | | | 13 | +++++++++++++ |
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/.local/bin/adcast b/.local/bin/adcast @@ -0,0 +1,29 @@ +#!/bin/sh +lockfile=/tmp/adcast.pid + +pass="$(gpg2 -q -d ~/.password-store/ad-server/adamsgaard.dk-icecast-source.gpg" + +startcast() { + ffmpeg -f sndio -ac 2 -ar 44100 -i snd/0 \ + -codec libmp3lame -f mp3 \ + icecast://source:${pass}@adamsgaard.dk:3232/live >/dev/null 2>&1 & + printf '%s' "$!" > "$lockfile" + + sleep 1 + if [ ! -f "$lockfile" ]; then + notify-send -u CRITICAL "${0##*/}" 'adcast did not start' + rm -f "$lockfile" + exit 1 + fi +} + +stopcast() { + kill "$(cat "$lockfile")" + rm -f "$lockfile" +} + +if [ -f "$lockfile" ]; then + stopcast +else + startcast +fi diff --git a/.local/bin/txt2pdf b/.local/bin/txt2pdf @@ -0,0 +1,13 @@ +#!/bin/sh +if [ $# -lt 1 ]; then + printf 'usage: %s <file.txt>\n' "${0##*/}" >&2 + exit 1 +fi + +fontsize=11 + +for f in "$@"; do + enscript "$f" -Bf "Courier${fontsize}" \ + -I "cat %s | iconv -c -f utf-8 -t iso-8859-1//translit" -p - \ + | ps2pdf - "${f%.*}.pdf" +done