X11

OpenBSD uses its own X11 version. This is called xenocara. It does the usual OpenBSD tricks with privilege seperation etc.

Change display resolution

Recently swonk was setting up a modern-ish PC with VGA. X11 defaulted to 1024x768 and didn't offer an option for the monitor (which could do 1080p). Extensive Internet searching found a few hints.

First, check the specs for the monitor. Next use the cvt program (part of X11) to generate a modeline that can be used to tell X11 about the monitor:

cvt 1920 1080 60

Now use xrandr (also part of X11) to create a new mode using the modeline cvt gave you.

xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync

Next, xrandr is used to identify the display:

xrandr --listmonitors

Using the monitor identifier (in this case, VGA1) xrandr is used to add that mode to the display:

xrandr --addmode VGA1 "1920x1080_60.00"

Finally, tell X11 to use the new mode.

xrandr --output VGA1 --mode "1920x1080_60.00"

The output changes and the monitor now displays 1920x1080 at 60Hz.

Make the change persist

The Internet suggested the xrandr commands should be put in the users .xsession to set the monitor resolution when you log in. This worked, but seemed to me to be cludgy. The display defaulted to 1024x768 after a reboot, only switching to 1920x1080 after the user login. Once it was set you could logout and it stayed in 1920x1080.

I was unhappy with this and did more digging. In the xenocara display manager, which is what displays the login prompt for X11, you have a script that sets up the login screen. So I moved the xrandr commands into /etc/X11/xenodm/Xsetup_0. Now on startup X11 starts in 1024x768, but switches to 1920x1080 before showing the login screen.

startx and rotate

For another use a similar monitor was used in the portrait orientation. This time the X11 server was started from the command line with startx instead of using xdm for a graphical login. startx looks for a .xinitrc on startup, so all the setup commands got there:

xrandr --newmode "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VGA-1 "1920x1080_60.00"
xrandr --output VGA-1 --mode "1920x1080_60.00"
xrandr --output VGA-1 --rotate right
/usr/local/bin/firefox --kiosk https://swonkdog.com