UI tweaks on OpenBSD


UI tweaks on OpenBSD

When not using a desktop environment, X, GTK and Qt have to be configured to work well with HiDPI screens, enable dark mode and more.

Tested on OpenBSD 7.4.

Configuring X for HiDPI

X can be configured to be used on HiDPI screens. Set the Xft.dpi X resource to 192 (default is 96) by adding the following line in the file ~/.Xresources:

Xft.dpi: 192

And add the following line in ~/.xsession to take ~/.Xresources into account. Be sure to add it before exec <window-manager>.

xrdb -merge ~/.Xresources

X started manually (not by xenodm)

If you use xenodm as display manager, you can ignore this section.

If you don't use xenodm but instead start X manually, you could need to use ~/.xinitrc. The following command creates a symlink to have a .xinirc identical to .xsession:

$ ln -s ~/.xsession ~/.xinitrc

Otherwise, you can just copy & paste the xrdb command above in your ~/.xinitrc file.

Changing cursor theme

It's possible to use a custom cursor theme, to have more modern, bigger, or HiDPI-ready cursors.

Downloading a cursor theme

You can find cursor themes on websites like Gnome Look, Deviant Art or Open Desktop. In this example I will download the cursor theme Capitaine Cursors, the downloaded file is capitaine-cursors-r4.tar.gz. Download the -light version if you prefer white cursors.

Installing the cursor theme

The steps to install the cursor theme are the following:

  1. The archive previously downloaded must be uncompressed in ~/.local/share/icons/, creating a subfolder with the theme name.
  2. The directory ~/.icons/default/ must be created
  3. A symlink has to be created at ~/.icons/default/cursors/ to point to ~/.local/share/icons/<theme-name>/cursors/
  4. The file ~/.icons/default/index.theme must be created
# Uncompress the downloaded archive and move it in the icons directory
$ cd ~/Downloads && tar -xzf capitaine-cursors-r4.tar.gz && mv capitaine-cursors/ ~/.local/share/icons/
$ mkdir -p ~/.icons/default/ && cd ~/.icons/default/
# Make the default cursors directory points to the theme previously downloaded
$ ln -s ~/.local/share/icons/capitaine-cursors/cursors cursors
# Enable the previously downloaded theme
$ echo -e "[Icon Theme]\nInherits=capitaine-cursors\n" > index.theme

Configuring GTK

Enabling dark theme

UI is usually light by default, but it's possible to say applications we prefer dark theme.

Edit the files ~/.config/gtk-3.0/settings.ini and ~/.config/gtk-4.0/settings.ini:

[Settings]
# Prefer dark theme
gtk-application-prefer-dark-theme=1

Setting font name & size

It's possible to change the font name and/or size used in applications. Edit the files ~/.config/gtk-3.0/settings.ini and ~/.config/gtk-4.0/settings.ini:

[Settings]
# Set the font name & size in GTK apps.
# Examples: Firefox & Chromium UI (tabs, URL bar, etc)
gtk-font-name=DejaVu 12

Configuring Qt

Qt has its own tool to configure the applications. Steps are as follow:

  1. Install qt6ct (use qt5ct instead of qt6ct for Qt 5)
  2. Set the environment variable QT_QPA_PLATFORMTHEME to qt6ct
  3. Launch qt6ct, and select your theme (e.g. Fusion), color scheme (e.g. darker) in Appearance > Palette > Custom > Color scheme
  4. Logout & login of your X session, it should work.
# pkg_add qt6ct
$ echo 'export QT_QPA_PLATFORMTHEME=qt6ct' >> ~/.profile
$ qt6ct

Note: in Fish: use set -Ux QT_QPA_PLATFORMTHEME qt6ct to create a universal environment variable.