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 : ) …

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 Responses to “moc, screen and figlet: A sum greater than its parts”

  1. 1 Abe Akesson 2010/04/18 at 10:34 AM

    Very nice. I used to run Moc and I never realized it could do that.

  2. 2 bryan 2010/04/18 at 1:19 PM

    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

  3. 3 fuxter 2010/04/25 at 10:55 AM

    hey, doc, did you see this monster

    haven’t tried it… and i guess i won’t..

  1. 1 Improving the mocp status screensaver « Motho ke motho ka botho Trackback on 2010/04/28 at 10:47 PM

Leave a Reply

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

You are commenting using your 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


Visit the Wiki!

Some recent desktops

May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF

May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games

Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers


This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,963,317 hits



Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: