me

notes from mnlwldr

Thoughts about programming and other things I want to share

@mnlwldr on Twitter @mnlwldr on GitHub @mnlwldr on Mastodon mnlwldr@gmail.com defer.cc

Bash

Posts tagged as Bash

Moved my somafm ‘player’ to bashrc

_somafm() { 
   mpv $1 2> /dev/null | awk '/title/ { s = ""; for (i = 2; i <= NF; i++) s = s $i " "; cmd="(date +'%H:%M:%S')"; cmd | getline d; print d,"|",s; close(cmd) }' 
}
alias groovesalad='_somafm "http://ice.somafm.com/groovesalad-128-aac"'
alias defcon='_somafm "http://ice.somafm.com/defcon-128-aac"'
alias deepspaceone='_somafm "http://ice.somafm.com/deepspaceone-128-aac"'

Don’t forget to support

Tags: #bash #somafm

Listen to somafm from the command line.

#!/bin/sh

DEFCON="http://ice1.somafm.com/defcon-128-aac"
GROOVE="http://ice1.somafm.com/groovesalad-128-aac"
DEEP_SPACE_ONE="http://ice1.somafm.com/deepspaceone-128-aac"
COVERS="http://ice1.somafm.com/covers-128-aac"

case $1 in
        "defcon") URL=$DEFCON ;;
        "groove") URL=$GROOVE ;;
        "space") URL=$DEEP_SPACE_ONE ;;
        "covers") URL=$COVERS ;;
esac

echo "Listen to $URL"
mpv $URL 2> /dev/null | awk '/title/ { s = ""; for (i = 2; i <= NF; i++) s = s $i " "; cmd="(date +'%H:%M:%S')"; cmd | getline d; print d,"|",s; close(cmd) }'

Don’t forget to support

Tags: #bash #somafm

Found this tweet yesterday from Ryan and I did not know that either

I am shocked to discover that this works in bash from at least version 4.4.x:

🎃(){ 🎃|🎃& };🎃

Link to the original tweet here

Tags: #bash