A Quick Ratmen Tutorial

EDIT (2010-02-06): Ratmen and ratmenu syntax is identical so this applies to both programs. Feel free to comment if you have any questions. I received an IM asking for a screencast of ratmen(u) in action. As it turns out, I’ve again been running ratpoison most of the time the past few weeks so I’ll try to get one posted at my youtube account (and embedded in a separate post on this blog) in the coming days or weeks.

This is in response to linuxam’s question about ratmen, which I also use in other window managers.

First, you have to keep in mind that ratmen isn’t a menu program in the normal sense of the word. It’s basically a command line invocation, which is why users get the general command syntax when typing ratmen. This lends itself very well to scripting (wink). It also means it can be dynamic — since it’s invoked independently of everything else, it doesn’t require restarting.

Second, you’re not tied to one menu since it can be scripted. You’re limited to the number of free bindings available in ratpoison (or any other window manager) or the number of files your system can hold since you can presumably nest multiple ratmens within other ratmens (which may have some purpose if you have enough stuff to stick in menus but I only run a few). It’s entirely customizable which is why I prefer using it in other window managers.

Keep in mind the basic syntax in the –help/error message: you need to write a very simple shell script to serve as your menu. I’m attaching a screenshot from my laptop. I set up rox filer earlier this afternoon and am using oroborus (like ratpoison, oroborus has no menus or panels or stuff but it plays better with rox).

As you can see, I have three icons on top next to the Home folder that I dragged onto the desktop from my ~/bin directory. One is my main menu (displayed in the left box) and the other two are for remote access to other machines and a menu for system commands (umounting various devices, managing services, reboot, shutdown, etc.). This is the text for the main menu.

# my ratmen

ratmen  \
"opera" opera \
"gvim" gvim \
"aterm" aterm \
"eterm" "Eterm -F -xos4-terminus-medium-r-normal-*-*-140-*-*-c-*-iso8859-1" \
"gimp" gimp \
"mc" "aterm -T mc -e mc" \
"snownews" "aterm -T snownews -e snownews -u" \
"dillo" dillo \
"calcurse" "aterm -T calcurse -e calcurse" \
"mc podcasts" "aterm -T mc -e mc ~/podcasts/ /mnt/vl-hot/sda/vol1/audios/music/ " \
"mc astro" "aterm -T mc -e mc ~/ ~/astro/ " \
"sylpheed" sylpheed \
"elinks" "aterm -T elinks -e elinks" \
"firefox" /opt/firefox/firefox \
"gftp" gftp \
"xzgv" xzgv \
"transmission" transmission \
"screenshot" "sleep 4; import -window root screenshot-$(date +%Y%m%d%H%M%S).png"

Add paths if necessary (the PATH comment isn’t necessary). This is then made executable. Then add it to your .ratpoisonrc either via binding or definekey. My menus are all via definekey command, which I remember as P for programs, R for remote, S for system, W for open windows, etc. The basic syntax for that is:

definekey top M-P exec ~/bin/mymenu.main

(I use alt-capital letters so as to not conflict with other keybindings. Use what you like. You can just as easily use bind if you prefer ctrl-t or whatever escape key plus whichever bind key.)

From the ratpoison wiki I got this for getting a ratmen of open windows from which to scroll:

definekey top M-W exec ratpoison -c "windows '%t|=#~ratpoison -c \"select %n\"'"|xargs ratmen --background grey22 --foreground yellow -d'|=#~'

Finally, you can set up ratmen variables in your .Xdefaults file. It’s hard to give it any aesthetic appeal unless you have some cool font you like. I stick with colors that contrast a little and then set up special color settings to override the defaults, such as the yellow and dark grey above or the red and black in my system menu. Here’s the ratmen settings from my .Xdefaults:

ratmen.style:            snazzy
ratmen.align:             left
ratmen.background:         grey22
ratmen.foreground:         darkorange
ratmen.font:            -xos4-terminus-medium-r-normal-*-*-200-*-*-c-*-iso8859-1
ratmen.mouse:             false
ratmen.scrollOffset:         5
ratmen.unfocusExit:         true

You can set ratmen.mouse to true if you want to be able to point and click on it (which I may do while I use it in oroborus). The choices between dreary and snazzy only have to do with how it scrolls. Dreary is the standard scrolling style where the highlighted part goes up and down while snazzy has a fixed (at top) position for highlight while the menu items scroll up and down.

It’s really very easy to get it set up once you have the basic idea down that it’s not a standard menu but rather a shell script. From there, it’s just a matter of doing things your own way and “dressing it up” to suit your own tastes including nesting ratmens.

Hope this helps.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: