Cwm /


cwm is a very powerful window manager that is part of the base system for OpenBSD.

One strength is its ability to entirely emulate the mouse with keybindings. These keybindings are entirely programmable.

In ~/.cwmrc:

bind-key CS-h pointer-move-left
bind-key CS-j pointer-move-down
bind-key CS-k pointer-move-up
bind-key CS-l pointer-move-right
bind-key CMS-h pointer-move-left-big
bind-key CMS-j pointer-move-down-big
bind-key CMS-k pointer-move-up-big
bind-key CMS-l pointer-move-right-big

C is control, M is meta (alt), and S is shift. This emulates the mouse movements to follow familiar vi keybindings.

Then, place this inside ~/.xsession:

/usr/X11R6/bin/xterm &

xenodm will now start an xterm and cwm upon successful login.

It may be convenient to place any terminals that need to be opened by default in a file like ~/

/usr/X11R6/bin/xterm -e 'sh -c \"sleep 1 && tmux new-session -A -s 0\"' &
/usr/X11R6/bin/xterm -e "sh -c \"sleep 1 && ssh -D 54321 -t \\\"tmux a -t 0; sh -l\\\"\"" &

To use keyboard keys to emulate a 3 button mouse in OpenBSD (on X11), first enable mousekeys:

$ doas pkg_add xkbset

Open xev and press keys you intend to use as mouse keys: might make lots of spam in terminal.

$ xev -event keyboard

My key codes are 75, 76, and 95 (F9, F10, and F11):

xkbset m # enables mousekeys
xmodmap -e "keycode 75 = Pointer_Button1"
xmodmap -e "keycode 76 = Pointer_Button2"
xmodmap -e "keycode 95 = Pointer_Button3"