support and follow me on Mastodon and Twitter

Tested on OpenBSD 6.3 and ThinkPad X1C5

Dock laptop with xrandr(1), xinput(1), xrdb(1), and sysctl(8)

TL;DR: Check out my dock and undock.


Toggle displays with xrandr(1). For example, only laptop's display (eDP-1) is on, then an external one (HDMI-1), then both side by side:

$ xrandr --output eDP-1 --auto --output HDMI-1 --off
$ xrandr --output HDMI-1 --auto --output eDP-1 --off
$ xrandr --output HDMI-1 --auto --output eDP-1 --auto --right-of HDMI-1

Mouse and touchpad

List all connected devices with xinput(1):

$ xinput
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ /dev/wsmouse0                             id=7    [slave  pointer  (2)]
⎜   ↳ /dev/wsmouse                              id=8    [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ /dev/wskbd                                id=6    [slave  keyboard (3)]

Then adjust button mapping and pointer acceleration. For example, reverse touchpad scrolling (id=7) and slow down trackball (id=8).

$ xinput set-button-map 7 1 2 3 5 4 7 6
$ xinput set-prop 8 'Device Accel Constant Deceleration' 5

See also my .xsession.


Toggle DPI for all X programs (including Firefox) and fonts for xterm(1). On high DPI screens, use large TrueType fonts:

Xft.dpi: 133
XTerm*faceName: DejaVu Sans Mono:size=12

On low DPI screens, use bitmap ones:

Xft.dpi: 92
XTerm*font: -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1

To apply these settings use xrdb(1) (don't forget to restart X programs after that):

$ xrdb .Xdefaults
$ echo 'Xft.dpi: 92' | xrdb -merge

Here is my .Xdefaults.


Define an action on laptop's lid closing. Do nothing (0), suspend (1), or hibernate (2):

# sysctl machdep.lidaction=0
machdep.lidaction: 2 -> 0
# sysctl machdep.lidaction=1
machdep.lidaction: 0 -> 1
# sysctl machdep.lidaction=2
machdep.lidaction: 1 -> 2