caedes' Notes


MCabber – Settings and rebinding of PageUp/PageDown

Filed under: Linux — caedes @ 00:34
Tags: , ,

After years of using centericq for ICQ and Jabber I switched to gajim (ICQ via transport), because centericq didn’t have any useable UTF8 support. I was never really satisfied with gajim though, because I happen to switch between my PC and my Notebook multiple times a day, resulting in inconsistent chat-histories etc – a console based solution in a screen is so much nicer.

So I tried MCabber, that turned out to be really great once you’ve configured it to your needs. After installing MCabber (most Linux/BSD distributions should have a package or port) you’ll want to configure it to your needs.

Create a .mcabber/ directory in your home-dir, with subdirs histo/ and otr/. Those directories should be only accessible by yourself (chmod 700) or MCabber will print out a warning at startup.

You’ll also need to put a mcabberrc file into ~/.mcabber/, the one that comes with mcabber (debian users will find it at /usr/share/doc/mcabber/examples/) is a good start and documented.

mcabberrc should have chmod 600.

I enhanced it a bit to suit my needs:

  • If you have a lot of contacts, a quick search function may come in handy. Usually its “/roster search somename”. I prefer just “/rs somename” so add alias rs = roster search to your mcabberrc.
  • Sometimes I want to scroll up the history – and don’t want it to scroll down if my buddy sends me a message. You can use “/buffer scroll_lock” and “/buffer scroll_unlock” or just “/buffer scroll_toggle” to achieve that. Just bind the toggling to F6, so you can enable and disable scroll lock with F6: Put bind 270 = buffer scroll_toggle in your mcabberrc.

Note: Why “270”? 270 is the curses-keycode of F6. At least on my box. On other systems or with other versions of the curses library (which mcabber uses) the keycode may be different.  Fortunately MCabber helps you to find out the keycode: just press an (unbinded) key in MCabber and something like [21:26:16] Unknown key=270 will appear in mcabbers log window.

MCabbers way of sending multi line messages is a bit unusual: First you have to start multiline mode (“/msay begin” or “/msay toggle”), then you write your message (just hit return once you’ve finished one line) and, when you’re done you send the message (“/msay send” or Ctrl-d).

  • I want to start multiline-mode with Alt-Enter (keycode M13 on my system), so I add the following binding: bind M13 = msay toggle

Now you should have a fairly useable config.

But there was one thing still that annoyed me: Going through the roster (contact list) is binded to PageUp/PageDown – and this is done in MCabbers code, not in the mcabberrc. My problem was, that the PageUp/Down-keys are next to the Enter-key on my Notebook. If I missed the enter key and pressed both PageUp/Down and Enter, the message would be sent to the next/previous contact in my roaster.. that sucks.

I decided to make PageUp/Down scroll the chat history and use Ctrl-PageUp/Down to move within the roster. To do that I need the keycodes of Ctrl-PageUp/Down (easy, because there is no hardcoded binding on them: MK3 and MK4 on my system) and of PageUp/Down – not easy, because MCabber doesn’t show the keycodes of binded keys.

The Solution: The curses keycodes are defined in /usr/include/curses.h – look for KEY_NPAGE and KEY_PPAGE. If you can’t find curses.h, you probably haven’t installed the curses development package (on debian it’s called libncurses5-dev).

You’ll get octal values (like 0522 and 0523 in my case) that need to be translated to decimal values to get a keycode for MCabber:

PageDown: #define KEY_NPAGE 0522 0522 is an octal value, convert to decimal (right to left): 2*8^0+2*8^1+5*8^2 = 2*1+2*8+5*64 = 338

PageUp is KEY_PPAGE, defined as 0523 (on my system), which translates to 339. Add the following to your mcabberrc to change the semantics of PageUp/Down and Ctrl-PageUp/Down:

# Ctrl-PGUP/DN -> move in contact list
bind MK3 = roster up
bind MK4 = roster down
# PGUP/DN -> scroll in message history
bind 339 = buffer up
bind 338 = buffer down

My (poorly documented) mcabberrc can be found here.

Last but not least: I find it convenient to have a sensible window-title in the terminal running MCabber (in screen). Most common terminal emulators (xterm, urxvt, Gnome Terminal, xfce terminal, …) can handle the xterm escape sequence to set the title (see this page for more information).

So I created a simple shellscript to execute before starting mcabber, like this:

$ "MCabber" && mcabber looks like this:

printf '33]2;%s07' $1

Please leave feedback in the comments, if you found this useful or have any suggestions.


– Daniel


1 Comment »

  1. I am using macbook (on linux) and there are no page up/down keys readily available; so I preferred using something else for scrolling the roster (e.g. ctrl-up/ctrl-down). The info on getting page up/down keycodes’ great; nice post! Cheers, Milen

    Comment by Milen — 2012-03-13 @ 07:46 | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your 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

Blog at

%d bloggers like this: