Spotlight Application: HOWTO rock better, faster, harder with cmus (Part 1 of ?)
I promised some more serious in-depth reporting now that my life has calmed down a little bit, so here we go with a walkthrough for a wonderful and underappreciated application, cmus. This post started as just a brief introduction, but as I dug into it, I realized this sucker was gonna get long. Also, although the documentation for cmus is really good, there’s a total lack of howtos for this application on the interwebs, and as Greg will tell you, we here at Guerrilla Tech are committed to caulking all the holes! (There’s a good story that goes along with that, but you know, never mind.)
So I’ve been idly looking at text-based audio players for a while, but yesterday I was sitting here playing Civ 4 on my Windows partition (I have a dual boot machine, Kubuntu/Civ 4) and was suddenly and irresistibly seized with the need to listen to some Nightwatchman right now. So I fired up the laptop and looked at some of my notes from last time I had this thought, and did a little google fishing for a non-graphical music manager. My criteria:
- Not a player, a manager. I’m demanding when it comes to my music management software. I run Amarok on my Kubuntu desktop and gmusicbrowser on my Gnome laptop. After experimenting with just about every free software music management/jukebox application that I could find in the repositories at least once, I am convinced that these two are absolutely the best of their breed (yes, that was two plugs for the price of one, slick, eh?). Music is a large part of what I do with my computer every day, I need a program that can keep up with my listening.
- Something with a relatively easy initial learning curve, and solid documentation. I don’t expect to master the program in half an hour (in fact, if I can master it in half an hour, it’s probably not what I’m looking for), but I should at least be playing music within half an hour.
- .mp3, .ogg, and .flac support.
- It must exist in the Ubuntu repositories.
Enter cmus, the c* music player. Install with sudo aptitude install cmus, fire it up with cmus, and we’re on our way. Let’s do a walkthrough, huh? (Remember, kids, for best results with any howto, always follow along in The Fabulous Manual! It’s quite comprehensive, and much of the material here was been lifted verbatim. I hope no one minds.)
Quickstart
Upon starting cmus, the first thing you’ll be greeted with is the library view. The first time you run it, you’ll see two empty panes because you haven’t loaded anything yet, so let’s remedy that, shall we? Type :add /path/to/music (you’ll notice your keystrokes being echoed in the command line at the bottom) and marvel in stunned awe at how fast cmus indexes your audio files. Just as a datapoint benchmark, I have just north of 45 days worth of audio on my server. Amarok (using sqlite) takes an hour or so to scan it all the first time. Gmusicbrowser, a little longer, hour and a half, maybe two. Cmus, on my KDE4 desktop (which has been very sluggish at times, for all its myriad virtues), just now as I am typing this, eight minutes. I didn’t time it on the server, but it was faster. (And yes, I know that cmus’s indexing of files and Amarok’s database are two very different critters.)
So now you’ve got a list of artists in the left pane. If you just want to skip to the music, just pick an artist and press the spacebar to open a list of all the albums you have by that artist; we’ll get into searching in a bit, for now just use up and down to scroll around (oh, and PgUp/PgDn and Home/End do what you’d expect them to as well). Pick an album and press Enter to start playing the album, simple as that. You’ll see the bottom panels display the playing track and elapsed time.
View Modes
As we’ll discover, cmus is packed to the rafters with features, which revolve around two concepts, views and commands. We’ll cover commands as we go, but for now just remember that Space selects the track(s). There are seven views in cmus, corresponding to keys 1-7:
1. Library view. As we’ve seen already, this is a display of all your music, shown in a two-pane window. The left pane is the artist/album tree. Artists are sorted alphabetically, albums by year. Selecting an album will display its songs in the right pane. Move back and forth between panes with Tab.
2. Sorted library view. The same content as view 1, but displayed as a sortable list.
3. Playlist view. Just what it sounds like. An editable, sortable, shuffle-able playlist.
4. Play queue view. Looks like the playlist, but the contents of the play queue are played before anything else in line (i.e. the playlist or the library).
5. File browser view. Defaults to your home folder. You can scroll around in it as in the library view, or use :cd /another/dummy/path to change directories. Did I mention there was tab completion? There’s tab completion. Anyway, you can add music from here to either the library, the playlist, or the queue.
6. Filters view. We’ll cover this in the next post.
7. Settings view. I know you want to fuck with them, but resist the temptation for now, we’ll get there.
Selected and marked songs and moving, copying, and deleting within and between views
The selected track is the track the cursor’s over, duh (or the artist/album the cursor’s over in view 1). To mark a track (in views 2-4), press space; you’ll see it turn to a gray background. You can mark as many tracks as you wish.
You can copy marked or selected tracks (or folders in the library and browser views) from views 1-5, thusly:
- a copies to the library (views 1 and 2)
- y copies to the playlist (view 3)
- e copies to the end of the queue (view 4)
- E copies to the beginning of the queue
In views 2-4 you can move tracks within the list. Pressing p moves marked tracks to the spot immediately after the selected track; P moves them to the spot immediately before the selected track. If there are no marked tracks, p and P move the selected track down or up, respectively.
D removes marked or selected tracks from the current view (1-4) without confirmation. D will also delete files in view 5 or remove fiters in view 6 (it will ask for confirmation).
Commands
(or at least a very quick introduction thereto)
Commands in cmus are prefaced with the : character. Also, the most common commands are bound to single keystrokes; see the manual for the complete list of keybindings. As noted, there is tab-completion for both command names and paths; for instance if you type :c TAB, you’ll see the command line change to :cd. Tab again, it changes to :clear, and so on in alphabetical order. Up and down will browse your command history. Also, you don’t need to type full command names if the command is unambiguous (that is, if no other commands start with the same characters, for instance typing :a followed by a space will read as :add, and you’ll see that change in the command-line).
Six keybindings you should know right off the bat:
- “Activate”: Enter. Does different things in different views. In the library and playlist it starts playing at the selected song. In the browser it starts the selected song or opens the selected directory. In filter view it activates the selected filter. If that sounded confusing, just remember that Enter always does what you expect it to and you’ll be fine.
- Play: x. Different from activate in that activate starts playing the selected song, and play starts wherever you last stopped.
- Stop: v
- Pause: c
- Next: b
- Previous:z
…okay, that’s about where I’m gonna admit I’ve run out of steam on this post. I hope I’ve covered at least the very basics of manipulating and playing your files in cmus, so that even if I were to never finish this, you would be able to install and use cmus (at least on a basic level) using just the information I’ve included here.
But have no fear, comrades! I’ll be back soon with installment two of this, in which we will cover some more advanced commands, making and using filters, and what all those settings in view 7 do. Something else I didn’t cover that you need to know right now? Drop a comment, I’ll get back to you.
-pd-
April 23, 2008 at 4:41 pm
Still waiting for part 2 …
April 24, 2008 at 7:31 am
Well, I will be damned, someone read this! All right, I kind of forgot about it but I still have a draft of the beginning of part 2. I’m going to be busy with the 8.04 release shenanigans, so give me a week.
April 25, 2008 at 7:22 pm
Thanks for the how-to, it helped
May 7, 2008 at 9:14 pm
great! thanks a lot for this how to! it helped me so much…
May 26, 2008 at 12:04 am
Also looking forward to future posts.
July 4, 2008 at 5:19 pm
graet job - I’m using cmus 2nd day - and I had little problem with all shorts and kaybinds.
thanks a lot.