I have become a big moc (music-on-console) fan. I recommend it to anyone who is looking for a command line substitute. Despite being superlight, it accomplishes all the task that any other audio player can do.
To install moc on Debian/Debian-based system, type in the terminal :
sudo apt-get install moc
To start moc, type
mocp in the terminal. The default layout will look something like this:
The whole look and feel will remind you of midnight commander. The screen is divided into two sections, directory structure on the left and playlist on the right. You can navigate to your desired directory or file using the up, down and enter key. You get a ../ at the top that will let you go to the parent directory.
To play a track just press enter after you have located the song. There is no need to add a song to the playlist, you can play tracks straight away from the directory list. Just navigate to the song and hit ‘Enter‘.
However, if you do wish to add a song or a directory to the playlist, just press ‘a‘ and it will be added to your playlist. moc remembers the playlist between sessions, unless you clear it. You can pause the track with both spacebar and ‘p‘. Same keys will play it again.
If you have loaded a playlist, you can search for a track using ‘g‘ or ‘/‘. With key ‘S‘ you can toggle shuffle on or off . The keys ‘n‘ and ‘b‘ will play the next and previous tracks, respectively. The left arrow and right arrow keys seek through the song. Volume can be increased with ‘>‘ and ‘.‘ and decreased with ‘<‘ and ‘,‘ . To delete a track from playlist, press ‘c‘. To delete the entire playlist, press ‘C”.
You can save the current playlist with ‘V‘. The playlist will be saved in the directory where you currently are in the directory list. To delete the playlist you have to delete it from the command line or from the file manager.
Didn’t like the default theme? No problem, you can change the theme with ‘T ‘, this will give you a list of themes to choose from. You can also create your own themes. Just remember, themes will only change the colors. If you wish to change the layout, it can be changed by pressing ‘l ‘. More on this later.
In Ubuntu, the sample configuration file is located at /usr/share/doc/moc/examples/config.example.gz. Extract the contents to ~/.moc and rename the file as ‘config‘. This is where moc starts to get flexible. You can do a lot of stuff from the config file, you can specify your music directory and on pressing ‘m ‘ you can quickly navigate to this directory no matter where you are in the directory list.
# Directory in which you store music files. If you specify it you will be able
# to quickly go to this directory with the '-m' parameter or the 'm' command.
# This can also point to a playlist.
MusicDir = "/home/sugandh/Music"
That’s not it, you can also specify upto 10 directories where you want to quickly jump. Use the keys ‘Shift+1‘, ‘Shift+2‘, ‘Shift+3‘ and so on.
# FastDirs, these allow you to jump directly to a directory, the key bindings
# are in the keymap file.
#Fastdir1 = /mp3/rock
#Fastdir2 = /mp3/electronic
#Fastdir3 = /mp3/rap
#Fastdir4 = /mp3/etc
Fastdir5 = /home/sugandh/Music/other
Configuration file also allows you to change the layout of moc player or you can create your own custom layouts. At any time you can have maximum 3 layouts and switch between them using ‘l‘ key. Here’s how the layout section of my config file looks (Layout 3 is my custom-made layout) :
# Main window layouts can be configured. You can change the position and the
# size of the menus (directory and playlist). You have 3 layouts and switch
# between then using the 'l' key (standard mapping). By default only 2 layouts
# are configured.
# The format is as follows:
# Each menu is described in the format NAME:POSITION_X,POSITION_Y,WIDTH,HEIGHT
# NAME is directory or playlist.
# The other parameters define position and size of the menu. They can be
# absolute numbers (like 10) or a percent value of the screen size (like 45%).
# WIDTH and HEIGHT can have value of FILL which means fill the screen from
# the menu's position to the border.
# Separate menu descriptions using a space.
# Menus may overlap.
# You must describe at least one menu (default is to fill the whole window).
# There must be at least one layout (Layout1) defined. Others can be empty ("").
# Just one layout, the directory will occupy the whole screen, the playlist
# will have 1/4 of the screen size and be positioned at lower right corner.
Layout1 = "playlist:50%,50%,50%,50%"
# Layout2 = ""
# Layout3 = ""
# The screen is split into two parts: playlist at the top and the directory
# menu at the bottom. Playlist will occupy 10 lines and the directory menu
# the rest.
Layout2 = "playlist:0,0,100%,10 directory:0,10,100%,FILL"
# Default configuration:
# Layout1 = "directory:0,0,50%,100% playlist:50%,0,50%,100%"
# Layout2 = "directory:0,0,100%,100% playlist:0,0,100%,100%"
Layout3 = "directory:0,0,30%,100% playlist:50,0,FILL,FILL"
Configuration file also allows you to control other elements of moc player like repeating the playlist and a whole bunch of other stuff.
To quit moc press ‘Q ‘. If you’ll press ‘q ‘, the client will be closed but the server will keep on running, playing your songs in the background. This way you can use the same console without interrupting your music. You can again start the client from the same terminal or any other terminal.
At any point in time if you don’t remember which key does what, just hit ‘h‘ and a list of all the keybindings will be displayed. Infact, you can remap the keybindings as you like. You can find the sample keybinding file in /usr/share/doc/moc/keymap.example, just copy it in ~/.moc, rename it and specify it in the config file and you are done.
# Choose a keymap file (relative to ~/.moc/ or absolute path).
# Example keymap with description is included (keymap.example).
Keymap = /home/sugandh/.moc/testkeymap
Probably, the only problem that could bug you is that if you load a big playlist, moc might freeze when you try to quit. But, not to worry, there are workarounds:
- After hitting ‘Q ‘ or ‘q ‘, press ‘Ctrl+c ‘ you’ll exit straight away. However, your playlist will not be saved for next session.
- In your ~/.moc/config, set
ShowTime = yes. This will cause it to start reading time in background.
- Again, in the ~/.moc/config, increase
TagsCacheSizeto some value so that tags from all your files will fit in the cache. I’ve increased TagsCacheSize to 2048 from the default 256.
Well, that’s pretty much about moc in a nutshell. I guess, now you know why moc is such a great player :).