Skip to content

Instantly share code, notes, and snippets.

Created March 26, 2013 21:27
Show Gist options
  • Save anonymous/5249438 to your computer and use it in GitHub Desktop.
Save anonymous/5249438 to your computer and use it in GitHub Desktop.
shell script oneliner to next songs in a blacklist (but not explicitly ban them, so the blacklist can be easily toggled off) assumes ctl fifo and out files were created in ~/.config/pianobar and that pianobar is talking to them (ie, you're using headless_pianobar) also assumes a list of blacklisted songs is located at ~/.config/pianobar/blacklis…
# as a one liner, just to say I told you so:
tail -f $HOME/.config/pianobar/out | sed 's/\x1b\[2K/\n/g' | gawk -v HOME="$HOME" ' BEGIN { i=0; while((getline line<"blacklist") > 0) songs[line]; } { for(song in songs) { if ( $0 == song ) { print "Skipping "song; print "n" > HOME"/.config/pianobar/ctl2"; } } } '
# With whitespace to make it easier to read:
tail -f $HOME/.config/pianobar/out |\
sed 's/\x1b\[2K/\n/g' |\
gawk -v HOME="$HOME" '
BEGIN{
i=0
while((getline line<"blacklist") > 0)
songs[line];
}
{
for(song in songs) {
if ( $0 == song ){
print "Skipping "song;
print "n" > HOME"/.config/pianobar/ctl2";
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment