02
Apr
11

The ratpoison tutorial part 2

Having some of the basics covered it’s time to get comfy.

Make shortcuts

Everybody’s got a set of favorite apps that he/she uses a lot. This includes browsers, media players, text editors of some sort, etc. You can bind your favorite apps to key shortcuts for maximum performance. Hit

C-t :

and type the following after the prompt:

: bind f exec firefox

Voila! Next time you hit ‘C-t f’, you’re gonna fire up firefox. You can bind almost whatever you want to almost any key you like, the rules are:

  1. Making bind for an already binded key will override the previous one.
  2. Some keys have their names, etc. ‘/’ is called ‘slash’.
  3. Upper- and lowercase keys are considered different.
  4. It’s a good practice to bind to something easy to remember like key f for firefox. You can use the upper/lowercase distinction like a modifier, i.e. I’ve got two dictionaries bound to ‘C-t d’ and ‘C-t D’ and each of them translates in a different direction.
  5. For starters, do not bind too much at once.

Ratpoison commands

Before making a custom config file a brief word about ratpoison commands is more than necessary. Ratpoison is being controlled only by invoking commands. Keyboard shortcuts are, well, shortcuts for the commands, for instance (with default bindings):

C-t p (prev)

C-t n (next)

C-t k (kill)

As I already said, you can invoke commands by typing them in the box, and the box can be open with:

C-t :

Another way to invoke a command is to pass it to /usr/bin/ratpoison, for instance:
ratposion -c “next” typed under the shell should have the same effect as C-t n does, or typing `next` in the C-t : box. There you have it: three ways to invoke a command. Now there are lots of commands. However, two of them are ultra useful for the config file, namely:

bind [KEY] [COMMAND] – binds the key with the command:)

exec [NAME] – Execute a program with (`/bin/sh -c’).

echo [WHAT] – Displays a message in a ratpoison box.

If you’re stubborn enough, you can argue that we have a fourth way to invoke a ratpoison command with:

exec ratpoison -c “next”

by using a ratpoison command to spawn a process which runs a command, but that’s nothing new really. As you can see, parameters are optional. When no parameters are specified, ratpoison will display a box to enter the missing parameters.

Customize your config

As you might have already noticed, all the binding and changes get lost with every ratpoison restart. To apply all of them automatically at startup, put all of them in a file ~/.ratpoisonrc . Get comfortable with this file, as it is the one and only setting file of ratpoison. You can put comments with ‘#’.

This is an excerpt from my own config file:

# ratpoison config file at ~/.ratpoisonrc

exec xmodmap -e "keycode 133 = F30"

# exec gnome-settings-daemon
exec xfsettingsd
exec xterm

####################################################################
# RATPOISON MISC.

bind semicolon colon
bind colon exec
bind b prev
bind equal time
bind q only

####################################################################
# MULTIMEDIA

bind i exec ~/scripts/radio/radio.py
bind I exec ~/scripts/radio/radio.py -toggle
bind m exec mocp -f; sleep 0.1; ratpoison -c "echo `mocp -i | head -7 | tail -5`"
bind M exec mocp --toggle-pause && ratpoison -c "echo `mocp --format %state`"

####################################################################
# GROUPS/FRAMES

bind Delete gdelete
bind Insert gnew 2 
bind bracketright exec ratpoison -c "gnext" -c "other"
bind bracketleft exec ratpoison -c "gprev" -c "other"
bind backslash gmove
bind End groups

####################################################################
# APPS

bind X exec sleep 0.2 && xset dpms force off
bind o exec opera
bind f exec iceweasel
bind d exec xterm -e 'ydpdict'
bind D exec xterm -e 'ydpdict -p'
bind c exec xterm
bind C exec gnome-terminal

The config file is simple as can be: you put there your ratpoison commands, the same command we’ve been using all along. I believe that they are being executed line by line during startup. As you’d expect, `exec`s you put in your config file would also get executed when the config file is being processed – that is, on startup.

Yes, it is really that simple to add a script to startup. No tinkering with runlevels, no weird kde startup control panels, no need for a zilion posts on linux forums. I have a few things scheduled for startup:

  • exec modmap … – this names the windows key as F30, so I could later change the escape sequence C-t to the windows key. It is so comfortable I want to cry and doesn’t collide with anything serious. People visit and wonder why the windows key is the most worn out one:) But beware! Different keyboards/distros have different keycodes. More on this topic coming up.
  • exec xfsettingsd – I’d like to attribute this hack to myself, but I’m not that certain I haven’t found it on the Internet. Beware, it’s dirty. xfsettingsd is, well, xfce setting daemon. Apparently, you can run it without the rest of xfce. Why bother destroying my beautiful, lean setup with it? Well, I get usb stick automounting, visual themes for GUIs and multimedia keys on my laptop running out of the box. It works with gnome settings daemon as well. I’m not sure that it’s 100 percent safe (as in my-system-is-secure safe) though.
  • exec xterm – It’s always nice to start a day with a fresh terminal.

As you can see, the rest of the commands in the config file are binds:

  • bind semicolon colon – makes semicolon do what the colon key does (bring up the ratpoison command box)
  • bind colon exec – binds to exec with no arguments, which brings up the exec box (as C-t ! does)
  • bind m exec mocp -f; sleep 0.1; ratpoison -c “echo `mocp -i | head -7 | tail -5`” – changes the song in MOC (a music player), and notifies me what is the next song through ratpoison’s echo

The rest of the commands should now be easy to grasp; you can find all of them and more at http://www.nongnu.org/ratpoison/doc/index.html.

Oh, if you feel lost there’s a built-in cheat sheet of shortcuts (updated after binding) available with:

C-t ?

What’s next?

Well, there are still a few topics I’d like to cover:

  • binding the windows key as C-t – sure, there are tutorials out there, but I have a few things to add
  • dividing the screen – this is where many tutorials for tiling window managers would start. Personally I don’t use it that much, and I feel that being comfortable with doing real stuff is far more important than laying tiles
  • glitch with some java apps – note to self
  • how to handle GIMP (multi-windowed?) – all solutions out there are out of date; grab GIMP 2.8 (or later if it’s future already) and enable the single window mode
  • multiple monitors!

10 Responses to “The ratpoison tutorial part 2”


  1. 1 David Wade
    November 3, 2011 at 9:53 pm

    Hi, I love your tutorials, you explain things perfectly, and have a great writing style.

    I’d love to see a stumpwm tutorial done by you, since it’s vastly super-seeded ratpoison now.

  2. 2 Black Napalm
    November 4, 2011 at 6:42 am

    Hello! I really like this ratpoison tutorial series. Is there gonna be continued?

  3. November 4, 2011 at 11:13 pm

    Hi! Thanks for comments, I’m really flattered. To be honest, I was kinda loosing hope that anyone will ever read my stuff. And I totally abandoned a thought, that anyone bothering enough to read it would get it:) As for Ratpoison: there’s a lot to be shared. Of course there are some tips scattered around forums, mostly custom-facepalm-configs (‘omg, how clever! why didn’t I come up with that earlier?’), but they’re hard to understand if you’re unfamiliar with the basics. So yea, you may expect a continuation anytime soon. As for stumpwm, I’m really afraid it will draw me away from ratpoison, so I’m kinda keeping my distance. But I’d really love to make a nice tiling wm comparison. With tables and fireworks.

    • 4 Vaskozl
      May 12, 2013 at 11:22 am

      “To be honest, I was kinda loosing hope that anyone will ever read my stuff. And I totally abandoned a thought, that anyone bothering enough to read it would get it:)”

      Here I am 2 years later, glad that you took the time to write this.

  4. 6 Byron Sanchez
    April 3, 2014 at 9:26 pm

    Thanks for this. Just getting started with ratpoison and this has helped me out 🙂 I’m loving it so far!

  5. June 23, 2016 at 3:00 am

    Thanks for this tutorial. I really enjoy using Ratpoison and appreciate your tips. I’m guessing that you aren’t adding more tutorials on it. If you do, please let me know.

  6. 8 Dallin Michael Hunter
    August 24, 2018 at 6:03 pm

    Greetings from 2018! This guide is still useful, thanks for writing it.

  7. 9 Austin Doiron
    January 29, 2024 at 12:56 am

    This is fricken awesome information. Thank you for your tutorials. Even now in 2024, these tutorials are like a gold mine. I started with fedora 37/Gnome/xorg, but f39/Gnome is getting a little bloated and ridiculous, so finding ratpoison along with these tutorials really helps a lot.


Leave a comment


April 2011
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930