I’ve posted before about why I like combinations like mocp, ratpoison, and ratmen(u). So why am I posting about this when I’ve covered similar things before? Because I’m getting occasional hits for “ratpoison audio level” and such things.
An important thing to remember about ratpoison is that it adheres to the Unix paradigm of doing one task very well and simply. As such, it doesn’t come with lots of add-ons and BS — it just manages windows with plenty flexibility. There are applications and utilities that lend themselves very well to ratpoison to manage other tasks like menus and playing audio which have nothing whatsoever to do with managing windows. Both ratmen(u) and mocp are examples, respectively.
Your distro or your flavor of BSD already contains utilities you can use to manipulate things like audio levels or other adjustments (I prefer ossmix or amixer to the mocp audio controls below but I want to show what I consider an easier way since those hitting this blog looking for search terms like those above most likely will be overwhelmed by more complex/granular utilities which vary depending how distros are assembled). Such command-line resources lend themselves well to scripting. And 9menu, ratmenu, and ratmen are scripting tools which work very well with window managers — like ratpoison — which allow users to set keybindings. This isn’t specific to ratpoison and could be made to work in just about any window manager (I’ve posted before about using ratmenu in oroborus and jwm; I’ve also written here about using command-line tools from within window manager menus).
I love ratpoison because it pretty much stays out of my way and gives me a full view of what I’m doing. I also love ratmen(u) — 9menu, which is “recommended” when using Debian apt-get/aptitude, works similarly so I suppose I should include it here — because it can be used however a user sees fit. Want to just have a choice of applications like most default window manager menus? Just do that. Want something that opens specific files in a certain manner in a particular application? You can do that. Mix and match. It gives you the full flexibility to do whatever you want.
That lends itself very well to console and command-line applications (not the same: console applications typically are built on libraries like curses to provide a more complex user interface while command-line applications are run straight from the command-line without an interface; some applications — including graphical ones — allow for command-line invocation of certain features). Not all console applications have such command-line options, but mocp does.
Building a ratmen(u) can be as simple or complex as you desire. In this case, I wanted one I could bind to one particular set of keys (meta-Y) to manage mocp functions; I’ve also done the same when running mpd, but I find myself using mocp more often. I also have another (bound to meta-M; mnemonic = music) which has some of my favorite streams and playlists set up in it. This allows me to fully control things as I desire without having to find whatever interface it’s playing in and then fiddle around with settings to play what I want, stop it, etc. I also have a menu set up to adjust PCM volume levels via mocp as well (mocp server doesn’t need to run to use it so it works for other apps which play back audio/video). So I can control all aspects of audio with simple menus rather than convoluted user interfaces which don’t work so well with keystrokes and require use of a mouse.
Here’s the menu I use to control mocp play, start, etc. It’s pretty straightforward. Remember that ratmen/ratmenu/9menu are normally run as shell scripts which need to be set executable.
I have it set up in my .ratpoisonrc to launch on the keybinding noted above. When I hit its binding, I get my menu atop whatever is open (if anything’s open at all):
I’m listening to a stream (Sky Smooth Jazz), so let’s say I want stream information and song title. Or I want to see the state of mocp (whether it’s playing, stopped, etc.). I can select the first choice here, which I have set up to give me the information in a ratpoison status line message:
That could be narrowed down via grep for artist/title or just state. Depends what you want.
The menu for my playlists and streams just uses the mocp options to clear (-c) the playlist, add (-a) a stream or playlist, and play (-p). I also have options to add playlists to the current one, etc. This integrates well with a shell wrapper I use for playing streams from my browser which is straightforward and set up as my default “player” for pls, m3u, etc.:
#!/bin/sh mocp -cap "$@"
That keeps stupid windows from opening up and getting in my way while I’m doing other things.
Like I wrote above, I also have an audio control menu which is built similarly. You could use whatever audio control software you have installed on your system to manage MASTER and PCM levels or you can use something like application mixer settings available through command line — depends what your preferred application allows. For this quick example, I decided to use the mocp controls since it’s simple and I also added an option to open a terminal with alsamixer for more control options. I also gave myself enough variables to get a desirable volume within a few keystrokes. There are much more clever ways to script such a thing, but this is just a quick example.
#!/bin/sh # my audio control ratmenu ratmenu -fg cyan -bg blue -align center \ "mute" "mocp -v 0" \ "volume 67" "mocp -v 67" \ "volume 80" "mocp -v 80" \ "volume +10" "mocp -v +10" \ "volume +5" "mocp -v +5" \ "volume +1" "mocp -v +1" \ "volume -15" "mocp -v -15" \ "volume -5" "mocp -v -5" \ "volume -2" "mocp -v -2" \ "alsamixer" "xterm -e alsamixer"
As I noted above, you can set up such adjustments for both PCM and MASTER with tools you already have installed. Those will work without regard for what you use to listen to music — whether XMMS, cmus, mp3blaster, mocp, mpc, etc. — but vary in difficulty in setting up.