moc, screen and figlet: A sum greater than its parts

moc users might know this and might not, but you can poll the moc server process to spit out information about the tune it’s playing. It’s something easier done than said, with just this command from a prompt:

mocp -Q %song

There are plenty of other variables you can use there; check the man page for a full list. You can also prepend that with a little explanatory text, and the output is adjusted properly. For example:

mocp -Q Now\ playing:\ %song

If you cull some error messages in the process (the Arch version will complain that it doesn’t have certain libraries installed, for example), that is easily corrected:

mocp -Q Now\ playing:\ %song 2>/dev/null

Pipe that through figlet, because small letters are boring:

mocp -Q Now\ playing:\ %song 2>/dev/null | figlet -t -c

Some crude looping, just for kicks:

while true ; do clear ; mocp -Q Now\ playing:\ %song 2>/dev/null | figlet -t -c ; sleep 15s ; done

The watch command might also be useful there. Dump that line into a file, set it to executable and cue screen to use it as the blankerprg. From screen’s prompt (CTRL+A : ) …

blankerprg script.sh
idle 90 blanker

Wait 90 seconds and bingo! a screensaver for the console that displays the tune currently playing. Isn’t Linux fun?! :mrgreen:

About these ads

5 thoughts on “moc, screen and figlet: A sum greater than its parts

  1. bryan

    You can do much the same thing with mpd and mpc with a small modification of the above command:

    while true ; do clear ; mpc | awk ‘/-/ {print $0} | figlet -t -c ; sleep 15s ; done

    Reply
  2. Pingback: Improving the mocp status screensaver « Motho ke motho ka botho

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s