Recently i decided to repurpose an old laptop as a server ( was still working fine and had a good processor (i5) ), as i didn’t need a gui i installed ArchLinux on it. Some of you who’ve used Arch before will know that it’s a very lightweight system.
After doing a basic install of lamp and vsftpd i decided to go ahead and also use it to play music. The reason i did it like this was because i wasn’t going to tuck the laptop away on some server rack, it’d just sit on my desk alongside my workstation. ( So why not save a couple percentages on cpu ^_^ ).
After doing some research i decided to install MOC which is the abbreviation for Music On Console. MOC is a lightweight cli music player with all the functionality that you’d find on a regular gui player installed out of the box ( except for visualization, but those are resource hogs anyway ).
So let’s get cracking and install this lovely player
Step 1 : Installing an audio driver
There are several options when it comes to audio drivers, however the most robust package in my eyes is ALSA ( Advanced Linux Sound Architecture ), this is already installed by default but do check if you’ve got the latest version installed.
- To check if alsa is installed
-
pacman -Q | grep alsa
- To install alsa
-
sudo pacman -S alsa-lib
Afterwards issue the following command to install the alsa utils package ( contains a cli soundmixer )
sudo pacman -S alsa-utils
Step 2 : Adding our user to the correct group
On archlinux your user by default doesn’t have access to the audio devices, as such you will need to add him to the ‘audio’ group. Issue the following command to do so
sudo gpasswd -a username audio
Take note that this will only take effect until the next time the user logs in.
Step 3 : Installing MOC
sudo pacman -S moc
After the installation has finished you can start your player by issuing mocp
In the beginning it might look a tad annoying to use, but after a while you’ll realise that it’s actually really easy to use.
Extra 1 : Shortcuts MOC
| Shortcut | Description |
|---|---|
| a | Add music files to the playlist |
| A | Add selected folder to the playlist |
| C | Clear the playlist |
| Right Arrow | Seek Forward |
| Left Arrow | Seek Backward |
| Spacebar ( or ) p | Play/Pause |
| s | Stop playing |
| S | Shuffle Playlist |
| R | Repeat Playlist |
| TAB | Switch between Panels |
| l | Switch between 1-panel or 2-panel view |
| N | Next Song |
| B | Previous Song |
| , | increase volume by 5% |
| . | Decreate volume by 5% |
| Q | quit mocp |
| ? | Help |
Extra 2 : Alsamixer
As i like to have my music playing in the background i usually just have mocp running under a different console ( switch between consoles by using alt + F[1-6] ) or just in the background ( use q to close mocp and have it running ).
As such i find it really useful to control my volume with alsamixer, you can compare alsamixer to a cli version of the gui sound control.
alsamixer
I hope you enjoy your newly installed music player
and remember happy coding !
Peter



