OpenBSD 7.4 with i3 wm
- What
- Preparations
- Patch and compile suckless terminal (ST)
- Create ~/.xsession
- Disable Xconsole
- Minor tweaks
- Keybinding cheat sheet
What
Desktop bootstraping notes for OpenBSD 7.4 with i3 wm and transparent suckless terminal.
Links
Preparations
Begin with adding your local account to doas.conf for simple elevation using doas -s
.
su root -c 'echo permit keepenv nopass ${LOGNAME} >> /etc/doas.conf'
Install packages
doas pkg_add i3 i3lock feh
Get the stock i3status config
cp /usr/local/share/examples/i3status/i3status.conf ~/.i3status.conf
Add locale and keep history to .profile
cat <<EOT >> ~/.profile
export HISTFILE=~/.ksh_history
export LC_CTYPE=en_US.UTF-8
EOT
Patch and compile suckless terminal (ST)
St has pledge(2) in the upstream source already, but an unspeakable entity from beyond time and space wants you to apply the following patches:
-
1 make file patch from OpenBSD st port that enables some OpenBSD specific build options
-
1 make file patch from OpenBSD st port correcting some color names
-
1 for “Scroll back through terminal output using Shift+{PageUp, PageDown}”
Build preparations
Download ST
mkdir ~/st
cd ~/st
ftp https://dl.suckless.org/st/st-0.9.tar.gz
tar zvxf st-0.9.tar.gz
Download patches
mkdir -p st-0.9/patches
ftp -o st-0.9/patches/st-focus-20230610-68d1ad9.diff https://st.suckless.org/patches/alpha_focus_highlight/st-focus-20230610-68d1ad9.diff
ftp -o st-0.9/patches/patch-config_mk https://raw.githubusercontent.com/openbsd/ports/master/x11/st/patches/patch-config_mk
ftp -o st-0.9/patches/patch-config_def_h https://raw.githubusercontent.com/openbsd/ports/master/x11/st/patches/patch-config_def_h
ftp -o st-0.9/patches/st-scrollback-0.8.5.diff https://st.suckless.org/patches/scrollback/st-scrollback-0.8.5.diff
Apply patches
cd st-0.9
patch < patches/patch-config_def_h
patch < patches/patch-config_mk
patch < patches/st-scrollback-0.8.5.diff
patch < st-focus-20230610-68d1ad9.diff
Opacity/transparency/alpha settings can be adjusted in config.def.h before compiling if needed.
Compile and install st
make
doas make install
The binary will be installed in /usr/local/bin/st
NOTE
st does not pickup all the environment variables from .profile for instance, so you need to set them manually in st.c if needed:
setenv("FANCY", "PANTS", 1);
The ‘1’ signifies that it will overwrite any existing value for the variable already set in the environment.
setenv(const char name, const charvalue, int overwrite); https://man.openbsd.org/getenv.3
Create ~/.xsession
Prepare ~./xsession with locale, xcompmgr (for delicious effects like transparency, shadows etc) and finally launch i3.
cat <<EOT >> ~/.xsession
export LC_CTYPE=en_US.UTF-8
xcompmgr -cCfF &
i3
EOT
Regarding setting the locale in .xsession, refer to OpenBSD FAQ - System Management:
“To use the Unicode character set in UTF-8 encoding wherever supported, set the LC_CTYPE environment variable to the value en_US.UTF-8:
- If logging in via xenodm(1), add export LC_CTYPE=“en_US.UTF-8” to your ~/.xsession before starting the window manager. See customizing X for more details.
- If logging in via the text console, add export LC_CTYPE=“en_US.UTF-8” to your ~/.profile. The text console’s UTF-8 support is a work in progress, and some non-ASCII characters may not display properly.”
Without this, in order for st to play well with characters like ‘åäö’ you need to launch st once again inside i3 as
LC_CTYPE="en_US.UTF-8" st
or make sure you manually set the environment variable.
Disable Xconsole
Disable that fugly Xconsole that pops up whenever you start your window manager:
In /etc/X11/xenodm/Xsetup_0, Comment out
sh “${exec_prefix}/bin/xconsole -geometry 480x130-“
Now reboot to have a clean start and then login through xenodm. When asked, generate an i3 config.
Edit the generated ~/.config/i3/config
and replace xterm with st:
bindsym $mod+Return exec /usr/local/bin/st
If you prefer login shell:
bindsym $mod+Return exec /usr/local/bin/st -e /bin/ksh -l
Add i3lock with black background:
bindsym Control+Mod1+l exec "i3lock -c 000000"
Now you can lock your screen with ctrl-mod+l.
Minor tweaks
Configure gaps between windows
Add some gaps (previously you would need i3-gaps for this)
The offical example here and below is a good start
# Configure 5px of space between windows and to the screen edges.
gaps inner 5px
# Configure an additional 5px of extra space to the screen edges,
# for a total gap of 10px to the screen edges, and 5px between windows.
gaps outer 5px
# Overwrite gaps to 0, I need all the space I can get on workspace 3.
workspace 3 gaps inner 0
workspace 3 gaps outer 0
# Only enable outer gaps when there is exactly one window or split container on the workspace.
smart_gaps inverse_outer
Set wallpaper
exec --no-startup-id feh --bg-scale images/puffy.jpg
Keybinding cheat sheet
Replace ; with ö on swedish keyboard.
Move window
Key | Function |
---|---|
mod+shift+j | move window left |
mod+shift+k | move window down |
mod+shift+k | move window down |
mod+shift+; | move focus right |
Change window focus
Key | Function |
---|---|
mod+j | move focus left |
mod+k | move focus down |
mod+k | move focus down |
mod+; | move focus right |
mod+h | split next new window horizontally |
mod+v | split next new window vertically |
Misc
Key | Function |
---|---|
mod+enter | spawn new terminal |
mod+shift+f | fullscreen |
mod+shift+space | make the window float |
Control+Mod1+l | lock screen |
mod+shift+e | exit i3 |
mod+shift+r | reload i3 conf |