Ratpoison - ArchWiki

Jump to content

# Ratpoison

2 languages

- 日本語
- 中文（简体）

From ArchWiki

Related articles

- Window manager
- Cagebreak
- Stumpwm

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: Poor style, duplicate content (Discuss in Talk:Ratpoison)

Ratpoison is a manually tiling window manager written in C that allows the user to manage graphical windows without a mouse. The user interface is inspired by GNU Screen.

By default, Ratpoison keybindings work quite similarly to Emacs and GNU Screen. Commands begin by pressing the prefix key (by default `Ctrl+t`), and are then followed by another key combination such as `Ctrl+Space` to move to the next window.

## Installation

Install the ratpoisonAUR package from AUR.

## Ratpoison and display managers

Many display managers (e.g., LightDM) source the available sessions from `/usr/share/xsessions/` and most window managers and desktop environments install their desktop entries there. However, Ratpoison instead creates a desktop entry file in `/etc/X11/sessions/ratpoison.desktop`. To allow display managers to find Ratpoison one may need to copy the Ratpoison to desktop entry `/usr/share/xsessions/ratpoison.desktop`. You can alternatively use a symbolic link. If the `/usr/share/xsessions` directory does not exist, create it as root.

## Using Ratpoison

To start Ratpoison, you need to first logout and select "Ratpoison" from your Display manager. Alternatively, you can configure xinit and use `startx`.

After X11 starts up you will see a black screen and a little textbox on the upper right of it that says "Welcome to Ratpoison". Now type `Ctrl+t` and then `?` to get a list of keybindings. If you are used to GNU Screen or Tmux, you will feel at home very soon.

You are able to define custom keystrokes and even override existing ones in `~/.ratpoisonrc`

Here is an example config file:

    ~/.ratpoisonrc

    startup_message off

    # run a programs at start.
    # you can also use ~/.xinitrc
    exec xsetroot -cursor_name left_ptr
    exec xterm

    # Setting the escape key to the Windows key
    escape Super_L

    # Keybindings for programs.
    # "bind" command requires that you first press the prefix key.
    # Overriding CTRL+t 'c' to start urxvt instead of default xterm.
    bind c exec urxvt -tr
    bind f exec firefox

    # Make a screenshot command for Ratpoison.
    # Bind it to Meta-Ctrl-PrintScrn.
    # Note that "definekey top" causes the keybinding to work without prefix key.
    alias sshot exec import -window root ~/screenshot-$(date +%F).jpg
    definekey top M-C-Print sshot

    # Virtual desks.
    # Note: you probably want to use rpws instead, read below.
    gnewbg one
    gnewbg two

    definekey top M-l exec ratpoison -c "select -" -c "gprev" -c "next"
    definekey top M-h exec ratpoison -c "select -" -c "gnext" -c "next"

    # switch between windows with vim-like keys, without having to press prefix key.
    definekey top M-j next
    definekey top M-k prev

    # Alt+Tab now switch to next window.
    definekey top M-Tab next

## Useful key bindings

Key bindings | Effect
--- | ---
`Ctrl+t` `!` <Program Name> | Start any program
`Ctrl+t` `?` | Show key bindings, even custom ones!
`Ctrl+t` `c` | Start xterm
`Ctrl+t` `n` | Switch to next window
`Ctrl+t` `p` | Switch to previous window
`Ctrl+t` `1`–`9` | Switch to windows 1–9
`Ctrl+t` `k` | Close the current window
`Ctrl+t` `Shift+k` | Kill the current application
`Ctrl+t` `s`,`Shift+s` | Split the current frame into two vertical,horizontal ones
`Ctrl+t` `Tab`, `Left`, `Up`, `Right`, `Down` | Switch to the next, left, top, right, bottom frame.
`Ctrl+t` `Shift+q` | Make the current frame the only one
`Ctrl+t` `:` | Execute a ratpoison command

## Tips and tricks

### Screen reader accessibility

By default, Ratpoison is not accessible with Orca screen-reader. There is a project at gitlab.com/stormdragon2976/strychnine that replaces the default Ratpoison widgets with GTK counterparts.

    $ git clone https://gitlab.com/stormdragon2976/strychnine.git
    $ cd strychnine
    $ ./setup.sh

Follow the on screen prompts, and you will get a `~/.ratpoisonrc` that will automatically launch Orca when it starts. See the included `README.md` for more options.

### Java applications

Java GUI applications assume stacking window managers, and do not go to fullscreen properly with the default Ratpoison configuration. See Java#Impersonate another window manager and Java#Gray window, applications not resizing with WM, menus immediately closing for solutions.

### Switch to another window manager temporarily

If a program misbehaves under Ratpoison, you can temporarily switch to another window manager. You need to be sure that your temporary window manager doesn't kill all programs when it exits. Notably at least IceWM is known to unfortunately not work because of that.

To switch to another window manager temporarily, you can use `tmpwm` Ratpoison command with `ctrl+t : tmpwm <RET>`

### Multiple workspaces

By default, Ratpoison only has one workspace. But Ratpoison comes with `rpws` script that can be used to add more workspaces.

Edit your `~/.ratpoisonrc`, and add:

    ~/.ratpoisonrc

    exec /usr/bin/rpws init 2 -k

That creates 2 workspaces. By default, you can access to them by using `Alt+F1` to access the first, `Alt+F2` to access the second, etc.

You can also add binds to them, like this:

    bind C-1 exec rpws 1
    bind C-2 exec rpws 2

That allows to access the first workspace with `Ctrl+t` `Ctrl+1` (assuming `Ctrl+t` as your escape/prefix key).

### URxvt and xterm

URxvt and xterm, as they are installed by default, send resize hints to the window manager. This works in most tiling window managers, but not in Ratpoison. The end result is that URxvt/xterm resizes itself in multiples of the font size, rather than resizing to the whole screen, and chances that there are unfilled gaps are high. There are two solutions to this problem, documented below.

#### Install a patched URxvt

If you use URxvt, the rxvt-unicode-fontspacing-noinc-vteclear-secondarywheelAUR package, among other improvements, sends no resize hints to the window manager. If you install this version of URxvt rather than the default, URxvt will resize properly within Ratpoison.

#### Adjust the border

We can use the URxvt/xterm option internalBorder and set the border of Ratpoison to 0.

A trial and error process must be done to find the exact number of internalBorder for each combination of resolution and font size. (the border of Ratpoison must be set to 0 before doing the tests) The term command line option `-b` can be used to test for the correct number and then can be saved on the following files.

    ~/.Xresources

    urxvt*internalBorder: 8 #change urxvt to xterm if necessary. Using the font terminus in urxvt at 14px size, 8 is the correct number here.

    ~/.ratpoisonrc

    set border 0

If a combination cannot be found, you could try changing the font size and the font family also (that changes the required border number).

### Autostart

Examples for launching programs when Ratpoison starts. File `~/.ratpoisonrc` is executed by Ratpoison on startup.

To launch URxvt with a Tmux session:

    exec urxvt -e bash -c "tmux -q has-session && exec tmux attach-session -d || exec tmux new-session -n$USER -s$USER@$HOSTNAME"

To launch Chromium with the cache in a tmpfs:

    exec bash -c 'pidof chromium &>/dev/null || exec /usr/bin/chromium --disk-cache-dir=~/tmp/cache'

### Wallpaper and transparency

Example for setting transparency using xcompmgr and Nitrogen. First start nitrogen and set the desired wallpaper. Then use this in your `~/.ratpoisonrc`

    Wallpaper and transparency

    exec xcompmgr -c -f -D 5 &
    exec nitrogen --restore

### Focus-follows-mouse (sloppy.c)

`sloppy.c` is a companion program for Ratpoison and can be found in `/usr/share/ratpoison/`. To enable focus-follows-mouse (also called "sloppy focus"), run the following commands:

    # cd /usr/share/ratpoison/
    # gcc -o sloppy sloppy.c -lX11
    # ./sloppy

To autostart focus-follows-mouse feature, add the following to your `~/.ratpoisonrc`:

    ~/.ratpoisonrc

    exec /usr/share/ratpoison/sloppy

#### ratpoison-sloppymove

Sloppy.c inhibits continued use of the keyboard to make focus changes. An improved version of focus follows mouse which does not interfere with keyboard-driven focus changes is available ratpoison-sloppymoveAUR

To autostart ratpoison-sloppymove, add the following to your `~/.ratpoisonrc`:

    ~/.ratpoisonrc

    exec ratpoison-sloppymove

## See also

- The Ratpoison documentation
- Ratpoison config sample
- Share your Ratpoison (experience) forum thread
- Collection of scripts for the Ratpoison window manager

Category:

- Tiling window managers

Hidden category:

- Pages or sections flagged with Template:Style