Skip to content

Instantly share code, notes, and snippets.

@rkfg
rkfg / gist:bf85ab97b9a7783e57f9
Last active August 29, 2015 14:27
PulseAudio monitor switch
#!/bin/sh
INDEX=$(pacmd list-source-outputs | sed -n 's#\s*index\: \([0-9]*\)#\1#p' | head -n 1)
if [ -z "$INDEX" ]
then
exit 1
fi
MONITOR=$(pacmd list-sources | sed -n 's#\s*name: <\(.*\.monitor\)>#\1#p' | head -n 1)
INPUT=$(pacmd list-sources | sed -n 's#\s*name: <\(.*_input.*\)>#\1#p' | head -n 1)
@rkfg
rkfg / stwatch
Last active August 29, 2015 14:06
#!/bin/bash
APIKEY=
ADDRESS=127.0.0.1:8080
WATCHDIRS=()
WATCHREPOS=()
TIMEOUTCHANGE=5
function watchdir {
local CHANGED
local EVENTS
@rkfg
rkfg / teatime
Created September 12, 2014 05:03
#!/bin/sh
TEACOUNT=8
TEADIV=
if [ -n "$1" ]
then
TEADIV="_$1"
fi
HASH=$(echo -n "teatime_$(date +%d-%m-%Y)$TEADIV" | sha256sum | sed 's/\([0-9a-f]*\) .*/\1/' | tr '[:lower:]' '[:upper:]')
TEANUMBER=$(echo "ibase=16; scale=0; $HASH % $TEACOUNT" | bc)
echo "HASH=$HASH\nTea count=$TEACOUNT\nTea number=$TEANUMBER"
@rkfg
rkfg / gifcreate
Last active February 4, 2021 21:01
GIF animation script to cut a piece of video and produce a frame-accurate optimized GIF with a precise framerate.
#!/bin/sh
help () {
log "Usage: `basename $0` [-h] [-n] [-a] [-u] [-s hh:mm:ss] [-d ss] [-w px] [-f n] [-S n] [-b n] [-t subtitle.sub] [-c default | basic | fontsize | fontstyle | full] <filename> [result.gif]
-h show this help
-n turn off subtitles
-a don't open directory with frames in filemanager
-u update this script from gist. Create .gifupd file in the script's directory to automatically check for updates once per day or put the number of seconds in the file to check with that period.
-s start time in seconds or as hours:minutes:seconds, default: 0