Login

Support

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.

Installation

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 michuk@polishlinux.org.

Add-Ons

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.
"NoCommand"
m:0x0 + c:160
NoSymbol

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:

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 and OSD

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.

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.

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?