MOC Audio Player — advanced tricks

[ Saturday, 28 July 2007, Treadstone ]

The program MOC was reviewed in recent article called MOC — Console Audio Player for Linux. It was written by Roman Tworkowski. Even though we live in the times of cute graphical interfaces e.g. Compiz, KDE, etc. I consider the MOC player to be a better solution for some users (including myself) than the very popular applications Xmms or Amarok, and the other visually appealing players. Why do I think so? Read on. I am about to describe some of the lesser known options of this excellent player.

My first argument for the MOC player is… the computer itself! I’m not going to deliver a lot of numbers to back up my statement, but some of you know very well what running a GUI based player like Amarok looks like on older or weaker machines. If the KDE environment wasn’t preloaded earlier, the graphical parts of Amarok alone force us to wait a long time before the player, with its libraries providing basic functionality, is loaded into the computer’s memory (so small in so many cases!).

The second argument for the player, perhaps the most salient one, is expressed best by this question: what are all those functions needed for? Let’s assume I’m a common man who wants to listen to music. I don’t need the music visualizations, the hundreds fancy skins, the fabulous image of my music player, the CD covers, or the advanced OSD (On Screen Display) modules. Really, the ability to listen to the music after logout is useful and appealing, you bet! Similarly, running the program from a console session might be beneficial if the X Window System went down “from an unknown cause”, especially after some new Linux tricks have been applied. :) And wouldn’t you like to play music during your system’s startup? Wouldn’t you like to control a player with a few commands, or make use of multimedia keys on your keyboards?

Are you swayed by these arguments? OK, let’s start then. :)


The installation process is easy, most distributions contain appropriate packages. I recommend you install moc-ffmpeg-plugin as well. You won’t be able to play wma, mp4, aac, and RealAudio files without this goodie. If distro makers do not provide the plugin you can download sources from the plugin’s official website.

Quick Start

Having gone through the installation process, the time for the first run has come. Type-in the mocp command in a console. A new window interface will pop up before your eyes. You can start playing music right away. To do this you have to find and mark music file in the player’s file manager (TAB will switch views) and press Enter. To stop playing press the “s” key, to pause press “p” or “space”. MOC makes intensive use of playlists. To add a new song to a playlist press “a”. If you want to add all song files from current directory press “a” and keep it pressed until all files are processed, or mark the directory and press “A”. Pressing “d” will delete a single item from a playlist; pressing “C” you’ll clear it all.

When your playlist is completed you’ll have to activate it using TAB. You’ll see the mark bar “jumping” to the playlist panel. Then press “l” (small letter l, like in llama :) ) – one of the two MOC panels will be closed leaving the MOC window with playlist contents. So use the TAB key to switch between the playlist view and the player’s view. A full list of the “key options” are shown at the end of the article.

Configuration File

I’ve attached an example config file below containing some comments. It is ready to use if you don’t want to fiddle with the configuration options – only the paths to directories should be changed.

If you configured the MOC player in different ways and you’d like to share the files with others, you are welcome to send them with short description to


Multimedia Keys in Keyboards – How to Use Them with MOC

Many modern keyboards are equipped with multimedia keys nowadays. They are sold with a set of drivers for Windows systems, why not make use of them under Linux (the keys not the drivers ;-) )? Luckily someone with the ability to do something about it had this idea and wrote the xbindkeys application which enables users to define all keyboard keys including multimedia ones. It should be available with most of the GNU/Linux distros. If not, its sources can be downloaded from author’s website and compiled according to provided method.

Having xbindkeys installed to hard disk you have to type in the following command in a console: xbindkeys -k. Then you should press the key you want to be bound to a command. You’ll see a message:

  Press combination of keys or/and click under the window.
  You can use one of the two lines after "NoCommand"
  in $HOME/.xbindkeysrc to bind a key.
      m:0x0 + c:160

The last three rows must be copied to ~/.xbindkeysrc. NoCommand must be replaced with one of the following commands (inside quotation marks)

mocp --play to run MOC server and start playing,
or to play files if MOC server
that has been started earlier; mocp --stop to stop playing; mocp --toggle-pause to pause on and off; mocp --next to play next song file; mocp --previous to play previous song file;

You can type in other commands, see the MOC manual for more, but the above commands are the most important ones, I think.

More information on xbindkeys can be found with “man xbindkeys” or reading documentation from the official website.

MOC & System Monitor

Surely, some of you have wondered whether something could be done to have the playing song’s name shown on your computer’s Desktop, or whether it’d be possible to integrate MOC player with system monitor? I wouldn’t bother to say this if it wasn’t possible! :) How to do it? The player has a useful parameter “-info” which displays data about its activity. There’s the Conky program as well, which shows other programs’ output in its own window. So putting all the information together one could write a short script to fulfill his wishes. Here’s a script created by Folken:


  TITLE="`mocp -i | grep 'Title:' | sed -e 's/^.*: //'`";
  if [ "$TITLE" != "" ]; then
    ARTIST="`mocp -i | grep 'Artist:' | sed -e 's/^.*: //'`";
    SONGTITLE="`mocp -i | grep 'SongTitle:' | sed -e 's/^.*: //'`";
    ALBUM="`mocp -i | grep 'Album:' | sed -e 's/^.*: //'`";
    if [ "$ARTIST" != "" ]; then ARTIST="$ARTIST - "; fi
    if [ "$ALBUM" != "" ]; then ALBUM="($ALBUM)"; fi
  else echo „MOC”

Simply stated, the script displays tags of the played file. If nothing is played the script writes a MOC message, where you can insert your own code, e.g. a message informing you the MOC is not running. Please keep in mind that MOC consists of two parts – a server and a client. To have the Conky showing its contents it’d suffice to add to its config file in an appropriate place:
${exec 30 /.sh | fold -w55 -s}

If using Conky is out of question you can make use of a gkrellm plugin or gnome-panel applet. You can compile the additional programs but you have to have their sources. I didn’t test them as I do not use either gkrellm or gnome-panel but you can write to me if you come across problems with them. I’ll write an article then in which I’ll describe the plugins’ installation and configuration steps.


MOC (Music on Console) got no facility to show text on a screen in OSD mode – it is only a console based program. Until a user called robo, wrote on his Czech blog two Bash scripts using the osd_cat application. He wrote how to make the MOC player display the playing song’s title, artist’s name, album’s data, progress bar, and volume bar.



  TOTALSEC=`mocp --info | egrep "TotalSec\:" | sed 's/TotalSec\:\ //'`
  CURRENTSEC=`mocp --info | egrep "CurrentSec\:" | \
  sed 's/CurrentSec\:\ //'`


  mocp --info | \
  egrep "^Artist\:|^SongTitle\:|^Album\:" | \
  osd_cat --offset=10 --indent=10 --color=$COLOR --font=$FONT \
  --shadow=$SHADOW &

  osd_cat --offset=120 --indent=10 --color=$COLOR --font=$FONT \
  --shadow=$SHADOW --barmode=percentage --percentage=$PERCENT



  # pasek lub procenty

  VOLUME=`amixer get Master | grep Front.Left\: | \
  sed -e s/"  Front Left: Playback [0-9]* \["// | sed -e s/"\%.*"//`

  osd_cat --offset=10 --indent=10 --color=$COLOR --shadow=$SHADOW \
  --barmode=$BARMODE --percentage=$VOLUME --delay=1

The first script shows song’s data. The second one shows current volume level – use it with the following commands:

amixer sset Master 1+ -- to increase volume level
  amixer sset Master 1- -- to decrease volume level

It’s a fairly good tool for volume control. You can do the same using xbindkeys like this:

 "amixer sset Master 1+;~/.skrypty/"
   alt + b:4

  "amixer sset Master 1-;~/.skrypty/"
   alt + b:5

These two entries in xbindkeys config file allow one to control volume level with the mouse wheel and the alt key. Moving the wheel up/down, and keeping left Alt button pressed, you’ll be able not only to change system volume but get feedback from a pretty progress bar, showing current volume level, as well. I invite those of you who have multimedia keyboards to investigate the above scripts.

MOC and Starting System

As I’ve mentioned, MOC can play files without running a character interface, and after the logout procedure. So why not add the MOC player to the startup scripts? That way the last system scripts could be run simultaneously with nice sounds played in a background. You only need to add to system services a script with mocp command. You’ll find short description how to do that in article about rTorrent.

I think you’ll find the above information useful and convincing. That consoles and applications or scripts written for them do not have to be any less useful than their GUI counterparts or difficult to get running. Perhaps also that they are the best remedies for some kind of problems new Linux users can run up against. And now, here’s the list of MOC option keys I promised to attach.

List of MOC Keys

  enter  -- starts playing
  s      -- stops playing
  n      -- plays next item from the playlist
  b      -- plays previous item from the playlist
  space  -- pause
  p      -- pause

  S      -- plays at random
  R      -- repeats the same song in a loop, 
	    Next (X button below) must be OFF
  X      -- switches to play sequentially
  o      -- plays a file from the Internet
  u      -- moves playlist item up
  j      -- moves playlist item down
  Ctrl+u -- adds the URL to the playlist
  g      -- searches marked string in file names
  /      -- searches marked string in file names

  r      -- rereads the directory
  T      -- switches to the theme selection menu
  f      -- toggles display mode of song titles
  TAB    -- switches marker bar between the playlist 
	    and the file manager panels
  l      -- switches between displaying the playlist 
            or the file manager panel
  P      -- switches full path in the playlist
  H      -- toggles hidden files view
  Ctrl-t -- toggles song duration time 
  Ctrl-f -- toggles format file view
  m      -- moves to directory entered in config file 
  G      -- moves to directory with currently played file
  i      -- moves to marked directory
  U      -- moves to upper directory
  a      -- adds a file to the playlist
  A      -- adds a directory recursively to the playlist
  C      -- clears the playlist
  V      -- saves the playlist
  d      -- removes marked item from the playlist
  Y      -- removes all empty items from the playlist

  < -- decreases volume by 1%
  ,      -- decreases volume by 5%
  >      -- increases volume by 1%
  .      -- increases volume by 5%

  x      -- toggles the mixer channel
  ?      -- shows help

  !      -- goes to a fast dir 1 (set in config file)
  @      -- goes to a fast dir 2
  #      -- goes to a fast dir 3
  $      -- goes to a fast dir 4
  %      -- goes to a fast dir 5
  ^      -- goes to a fast dir 6
  &      -- goes to a fast dir 7
  *      -- goes to a fast dir 8
  (      -- goes to a fast dir 9
  )      -- goes to a fast dir 10

  F1     -- executes ExecCommand1 (set in config file)
  F2     -- executes ExecCommand2
  F3     -- executes ExecCommand3
  F4     -- executes ExecCommand4
  F5     -- executes ExecCommand5
  F6     -- executes ExecCommand6
  F7     -- executes ExecCommand7
  F8     -- executes ExecCommand8
  F9     -- executes ExecCommand9
  F10    -- executes ExecCommand10

Why MOC?

I’m expecting one kind of questions in the comments in particular – why not MPD, which offers similar if not better functionality. I dunno. I use the MOC player myself and I find it more friendly for fresh Linux users than others. Besides this article was aimed at the newbies, wasn’t it?

Proof-read by chaddy

Subscribe to RSS feed for this article!


fold this thread Biffster  Monday, 30 July 2007 o godz. 11:56 pm #  Add karma Subtract karma  --1

If you like MOC, you should give mp3blaster a try. It is the best console-based music player I’ve seen. I’m still an Amarok guy, because I do like a lot of Amarok’s functions, and can’t live without it’s ability to handle a large library (17,000 songs). But when I just want to play a few songs, I fire up mp3blaster.

(Comments wont nest below this level)
fold this thread CD Baric  Tuesday, 31 July 2007 o godz. 8:40 pm #  Add karma Subtract karma  +1

Excellent article – will download and install today.

I am a great believer in the utility and power of the command line – I still use mplayer in command line mode for everything.

Thanks again,

CD ‘Bar’ Baric

(Comments wont nest below this level)
fold this thread pedro-kun  Friday, 3 August 2007 o godz. 12:29 pm #  Add karma Subtract karma  --1

Excelent article, indeed :)

I’m not gonna use moc, but i do use mpd all the time, which is pretty much the same thing, with some database capabilities.

I highly recomend this tutorial for everyone :)

(Comments wont nest below this level)
fold this thread Ravi S Ghosh  Saturday, 11 August 2007 o godz. 2:08 am #  Add karma Subtract karma  +1

Moc is better than mpd in my opinion since, mpd keeps on running all the time draining the processor even when it is not required.

(Comments wont nest below this level)
fold this thread tash  Tuesday, 30 October 2007 o godz. 4:26 pm #  Add karma Subtract karma  +0

i used to use mpd but switched to moc b. it more fits my needs, i’m not playing remotely and moc can play files straight from my hd which mpd cant.

(Comments wont nest below this level)
fold this thread finferflu  Monday, 24 December 2007 o godz. 5:48 pm #  Add karma Subtract karma  +0

@ Ravi S. Ghosh
While your argument is valid, I don’t think MPD is that heavy on resources, not even noticeable.

@ tash
I use MPD to play files straight from my HD. MPD can play both locally and remotely.

I personally like MPD a lot, but I’m not completely satisfied by the MPD clients. I only wish MOC had support for MPD.

(Comments wont nest below this level)
fold this thread Allison  Friday, 16 May 2008 o godz. 8:08 am #  Add karma Subtract karma  +0

Wonderful article. I use both Moc and Mpd. Even though Moc is my primary music player, My roomy loves Mpd + Sonata. I share my computer with her so it’s kind of give and take. Both are very cool music players!

For some time I’ve been trying to get a conky execibar to display a songs length correctly. I don’t know much about scripting, but I can sure botch up a script a perectly good script with some fiddling! How would you add that fuction to your script above?

(Comments wont nest below this level)
fold this thread LETRA  Saturday, 15 November 2008 o godz. 9:08 pm #  Add karma Subtract karma  +0

Good article, moc is my first music player option since three years. Thanks from Spain. Greets.

(Comments wont nest below this level)
fold this thread Laptop Pugilist  Tuesday, 17 March 2009 o godz. 3:43 am #  Add karma Subtract karma  +0

Great article, mocp is just what I didn’t know I was missing. Your scripts for conky are great too, though it’s faster to just call mocp -i once:


mocp -i > mocpinfo

STATE=”`cat /home/user/.moc/mocpinfo | grep ‘State:’ | sed -e ‘s/^.*: //’`”;
TITLE=”`cat /home/user/.moc/mocpinfo | grep -m 1 ‘Title:’ | sed -e ‘s/^.*: //’`”;
if [ "$STATE" = "STOP" ]; then echo „MOC”;
elif [ "$TITLE" = "" ]; then
FILE=”`cat /home/user/mocpinfo | grep ‘File:’ | sed -e ‘s/^.*: //’`”;
echo ” $FILE “;
else echo ” $TITLE “;

The speedup isn’t amazing unles (like I) you are also making a bar and paused/stopped indicator out of the same data. Those two scripts became three times as fast. As an added bonus it makes top look much neater!

(Comments wont nest below this level)
fold this thread spyro  Monday, 13 September 2010 o godz. 10:47 pm #  Add karma Subtract karma  +0

Being a new Linux-convert myself, I find this tutorial really helpful..just installed MOC in my PC and now enjoying this simple yet efficient program. I hope you continue writing tutorials/how-tos to help those like me who have just made the move to Linux..more power to you!!!

(Comments wont nest below this level)
fold this thread ac services houston  Friday, 6 July 2012 o godz. 12:01 pm #  Add karma Subtract karma  +0

Hello i am kavin, its my first occasion to commenting anywhere, when i read this piece of
writing i thought i could also make comment due to this brilliant

(Comments wont nest below this level)
fold this thread sacs longchamp solde  Thursday, 9 May 2013 o godz. 9:54 am #  Add karma Subtract karma  +0

This post presents clear idea designed for the new viewers of blogging, that truly how to do blogging.

(Comments wont nest below this level)
fold this thread microsoft point gratuit xbox 360 code  Sunday, 18 May 2014 o godz. 1:04 am #  Add karma Subtract karma  +0

Others think it was an oracle observatory where the shaman would go inside to observe a special star pass over “the lens” to signal an exact time or event of the year.
When: Wednesday, October 31, 2012 6pm to 9pm – Cost:
$5. Their roster included Debo Lishun, Roxie Barracuda, Wyatt
Riot, Millie Massacre, Scarlett Letter Have It, Fang Banger, Keip Wishin, Monkey,
Robbie Roll Bot, Double D Trouble, and Manic Mechanic. The top-dogging comes from
when your team’s so far in the lead that scoring becomes an afterthought.
Our poor chicken is now on a (dangerous) ninja quest to
prove to all of the other chickens that he is indeed a ninja.
The other JC recruit is defensive tackle Ioane Gauta, a 6-3, 310-pounder from Fullerton, Calif.

(They also often scream at their teammates like the coach.

(Comments wont nest below this level)
fold this thread details about the best electronic cigarettes online store  Saturday, 31 May 2014 o godz. 8:11 am #  Add karma Subtract karma  +0

Good day! This is my 1st comment here so I just wanted to give a quick shout out and tell you I really enjoy reading your
blog posts. Can you suggest any other blogs/websites/forums that cover the same subjects?
Thank you!

(Comments wont nest below this level)
fold this thread guinea worm  Tuesday, 8 July 2014 o godz. 3:33 am #  Add karma Subtract karma  +0

This article offers clear idea for the new visitors of blogging,
that genuinely how to do blogging.

(Comments wont nest below this level)
fold this thread La Mort aux trousses  Wednesday, 9 July 2014 o godz. 9:48 am #  Add karma Subtract karma  +0

Reality based films also grab the attention of many. He, along with the other townspeople, watches the beautiful theater being demolished.
There are several cinema news website which update the photos and videos of the wedding.

(Comments wont nest below this level)
fold this thread medicament crestor  Friday, 18 July 2014 o godz. 8:55 am #  Add karma Subtract karma  +0

It is definitely intended for use as a business grade laptop.

Broadly, radio controlled boats come in three different types of packages;
RTR kits, ARTR kits, and Assembly kits. This
will provide various sites that offer online jobs for
such skills.

(Comments wont nest below this level)
fold this thread  Saturday, 26 July 2014 o godz. 11:41 am #  Add karma Subtract karma  +0

I’m gone to tell my little brother, that he should also go to
see this webpage on regular basis to obtain updated from latest gossip.

(Comments wont nest below this level)
fold this thread  Sunday, 27 July 2014 o godz. 4:38 pm #  Add karma Subtract karma  +0

Know the Precise Lingerie Size of your Girlfriend – Don’t neglect that, her apparel measurement
and lingerie measurement is entirely distinct.
Whether you are looking for sheer and sexy see through teddy
or just something comfortable to wear under your
work clothes you will be able to find it online. It
is a perfect store to indulge in shopping for La Senza lingerie because of the prices offered by them.

(Comments wont nest below this level)
fold this thread Aurora Colorado Air Conditioning Repair  Wednesday, 30 July 2014 o godz. 7:00 pm #  Add karma Subtract karma  +0

Excellent site. A lot of helpful information here. I’m sending it to some buddies ans additionally sharing in delicious.
And obviously, thank you for your effort!

(Comments wont nest below this level)
fold this thread Plumbing Repair  Friday, 1 August 2014 o godz. 4:51 am #  Add karma Subtract karma  +0

I get pleasure from, lead to I found just what I was having a look for.
You have ended my 4 day lengthy hunt! God Bless you man. Have a
great day. Bye

(Comments wont nest below this level)
fold this thread  Wednesday, 13 August 2014 o godz. 10:17 pm #  Add karma Subtract karma  +0

C’est un génial poste à l’appui de toutes les en ligne téléspectateurs;
ils obtenir avantage de lui j’en suis sûr.

(Comments wont nest below this level)
fold this thread air conditioning repair Cleveland  Thursday, 14 August 2014 o godz. 1:48 am #  Add karma Subtract karma  +0

This blog was… how do you say it? Relevant!!
Finally I have found something that helped me. Appreciate it!

(Comments wont nest below this level)
fold this thread dental mesa az  Thursday, 14 August 2014 o godz. 4:51 am #  Add karma Subtract karma  +0

When someone writes an article he/she maintains the plan of a user in his/her mind that how a user
can be aware of it. Therefore that’s why this piece of writing is great.

(Comments wont nest below this level)
fold this thread Transformers La era de la extinción gratis  Thursday, 14 August 2014 o godz. 8:07 pm #  Add karma Subtract karma  +0

If you want a smaller but higher quality picture then a Plasma TV
would be a good option as these can be purchased at sizes up to 65 inches, and therefore still
providing you with a big screen viewing experience. But television do not provide the same pleasure of watching a movie
as does movie theatre with its huge screen and
surround sound system. But Alfredo’s death has released him from this

(Comments wont nest below this level)
fold this thread La Planète des singes l'affrontement Télécharger  Friday, 15 August 2014 o godz. 8:48 am #  Add karma Subtract karma  +0

The true filmaholic hears a song from the soundtrack and
knows exactly where it comes in during the film.
We guarantee your satisfaction, and we’ll
make your event special and memorable for an affordable price.
With Luigi Lo Cascio, Catrinel Marlon, Luigi Maria Burruano.

(Comments wont nest below this level)
fold this thread  Friday, 15 August 2014 o godz. 1:35 pm #  Add karma Subtract karma  +0

Simmply desire to say your article iss as surprising.
The clarity in your post is just cool and i could assume you’re an eexpert on this subject.

Well wifh your permission alow me to grab your RSS feed to keep updated with forthcoming post.
Thanks a million and please keep up the enjoyaboe work.

(Comments wont nest below this level)
fold this thread documentaire  Monday, 18 August 2014 o godz. 2:21 am #  Add karma Subtract karma  +0

Cool blog! Is your theme custom made or did you download it from somewhere?
A theme like yours with a few simple tweeks would really make my blog jump out.
Please let me know where you got your design. Cheers

(Comments wont nest below this level)
fold this thread ceramic window tint  Friday, 22 August 2014 o godz. 2:35 am #  Add karma Subtract karma  +0

Awesome! Its really remarkable post, I have got mսch cllear ideaa
ϲoncerning from this piece օf writing.

(Comments wont nest below this level)
fold this thread steam room shower  Thursday, 11 September 2014 o godz. 8:18 pm #  Add karma Subtract karma  +0

Come across this incredible website and ordered
a steam shower and never looked backwards, awesome info on this site cant
say thanks enough

(Comments wont nest below this level)
Name (required)
E-mail (required - never shown publicly)

Adjust field size: shrink | enlarge)

You can use simple HTML in your comments. Some examples are as follows:
  • A hyperlink: <a href="">GNU/Linux for everyone!</a>,
  • Strong text: <strong>Strong text</strong>,
  • Italic text: <em>italic text</em>,
  • Strike: <strike>strike</strike>,
  • Code: <code>printf("hello world");</code>,
  • Block quote: <blockquote>Block quote</blockquote>

About the Author

Łukasz Olender

New AdTaily ads!

Are you a film buff?

film buffs community, movie recommendations and reviews

RSS: Comments

You can follow the comments to this article through a special channel RSS 2.0 .

Related articles: CLI

 more »

Related articles: Multimedia

 more »

PolishLinux Top Content

Become our fan on Facebook! on Facebook

Follow PolishLinux on Twitter!

Follow polishlinux on Twitter

Google Ads