dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles # fast
git clone https://src.adamsgaard.dk/dotfiles.git # slow
Log | Files | Refs | README | LICENSE Back to index

adcast (589B)


      1 #!/bin/sh
      2 lockfile=/tmp/adcast.pid
      3 
      4 pass="$(gpg2 -q -d ~/.password-store/ad-server/adamsgaard.dk-icecast-source.gpg)"
      5 
      6 startcast() {
      7 	sndioctl -q input.level=1.0
      8 	ffmpeg -f sndio -ac 2 -ar 44100 -i snd/0 \
      9 		-codec libmp3lame -f mp3 \
     10 		"icecast://source:${pass}@adamsgaard.dk:3232/live" >/dev/null 2>&1 &
     11 	printf '%s' "$!" > "$lockfile"
     12 
     13 	sleep 1
     14 	if [ ! -f "$lockfile" ]; then
     15 		notify -u CRITICAL "${0##*/}" 'adcast did not start'
     16 		rm -f "$lockfile"
     17 		exit 1
     18 	fi
     19 }
     20 
     21 stopcast() {
     22 	kill "$(cat "$lockfile")"
     23 	rm -f "$lockfile"
     24 }
     25 
     26 if [ -f "$lockfile" ]; then
     27 	stopcast
     28 else
     29 	startcast
     30 fi