Skip to content

Instantly share code, notes, and snippets.

@Donearm
Last active September 2, 2021 09:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Donearm/1035677 to your computer and use it in GitHub Desktop.
Save Donearm/1035677 to your computer and use it in GitHub Desktop.
Script to capture info on currently playing song in MPD, add an (optional) prefix and/or suffix and tweet it all via TTYtter
#!/bin/sh
# Script to capture info on currently playing song in MPD, add an
# (optional) prefix and/or suffix and tweet it all via TTYtter (which
# must be of course already been configured)
#
# Dependencies: TTYtter, a MPD client that can output song info (I use
# ncmpcpp)
PREFIX='on air: ' # what should go before the now playing string
SUFFIX=' #NP' # what should go after the now playing string
# save the now playing string from the mpd client of choice (it and
# format can be of course changed according to one's tastes
NP=$(ncmpcpp --current-song "%a - %t")
if [ -z $NP ]; then
echo "Can't get the current song, is MPD playing?"
echo "Or perhaps the MPD client isn't working/displaying song info correctly?"
exit 1
else
continue
fi
STATUS="${PREFIX}${NP}${SUFFIX}"
echo $STATUS
ttytter -rc=-donearm -script -status="$STATUS"
exit 0
@9mmtylenol
Copy link

Pretty convenient thanks!

@cirrusUK
Copy link

due to ncmpcpp upstream changes, edit line
NP=$(ncmpcpp --now-playing "%a - %t")
to
NP=$(mpc current)

@masala-man
Copy link

The option's been renamed to --current-song

@Donearm
Copy link
Author

Donearm commented Oct 23, 2019

Update the gist, thanks @masala-man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment