With OpenBSD successfully installed on the HP Stream 11, I want to adjust a few of the settings to be more to my liking, and to prepare it for it's job of being a simple laptop to take on trips.
These changes can be done in almost any order; but generally I start by tweaking the system, and then the interface, but you can't do the two completely separately.
A lot of this comes from OpenBSD on a Laptop [c0ffee.net] and Running OpenBSD 7.3 on your laptop is really hard (not) [Keith Burnett], but with changes specific to me and this toy laptop.
At the moment not everything works perfectly, and after some sections there will be a 'comments' sub-heading that explains how I arrived at those choices, or the bits I've not really understood, but feel free to ignore them if all you want is the set up. If you spot anything that's wrong, or could be done better, please let me know and I'll be happy to update this page.
Post Install Updates and Configuration Changes
Assuming you're seeing the FVWM desktop after a first login we can start making the first adjustments. In the open Xterm window switch to the root account by typing su and then the root password.
Setup a Text Editor
To make these changes you'll need to use a text editor. Three come as part of the base system, vi, mg and the graphical xedit, which is probably the most 'friendly' if you're unsure. Alternately if you want to edit from the command line I'd probably recommend installing the nano editor for editing files easily from the command line with pkg_add nano.
My personal revelation was mg editor and is a light Emacs-like editor if you're already accustomed to Emacs keybindings (shortcuts) and all you want to do is edit text1. Since I use Emacs for most things this is the easiest option for me. If you're also going to use mg, then it's worth creating a .mg config file in the /root directory with the option that makes it save all backup files in a .mg.d directory in your (or root's) home directory, otherwise it leaves backup copies of files scattered through the file-system. (You can spot them, as they are the file name with a trailing ~.) Do this for the root account with:
# echo 'backup-to-home-directory 1' > /root/.mg
Repeat for your own account if necessary.
Run Updates
As root run syspatch and then pkg_add -u to make sure everything is up to date first.
Additional Privileges
We don't want to be running as root for longer than necessary, so give yourself doas access.
# echo 'permit persist keepenv USERNAME' > /etc/doas.conf
Add yourself to the "staff" group for more system resource access, and the "_shutdown" group so you can turn off the laptop without needing to use doas:
# usermod -G staff,_shutdown USERNAME
You can now turn off the machine with shutdown -p now and not type in a password.
Performance
Once added to the staff group, you can adjust the limits set in /etc/logins.conf to be higher, which should help with that demanding web browsing.
staff:\
:datasize-cur=infinity:\
:datasize-max=infinity:\
:maxproc-max=512:\
:maxproc-cur=1024:\
:ignorenologin:\
:requirehome@:\
:tc=default:/etc/login.confThe next improvement is to add the options "softdep"and "noatime" to your partitions in /etc/fstab - except for the swap partition.
YOUR_DISK_ID.b none swap sw
YOUR_DISK_ID.a / ffs rw,softdep,noatime 1 1
YOUR_DISK_ID.l /home ffs rw,softdep,noatime,nodev,nosuid 1 2
YOUR_DISK_ID.d /tmp ffs rw,softdep,noatime,nodev,nosuid 1 2
YOUR_DISK_ID.f /usr ffs rw,softdep,noatime,nodev 1 2
YOUR_DISK_ID.g /usr/X11R6 ffs rw,softdep,noatime,nodev 1 2
YOUR_DISK_ID.h /usr/local ffs rw,softdep,noatime,wxallowed,nodev 1 2
YOUR_DISK_ID.k /usr/obj ffs rw,softdep,noatime,nodev,nosuid 1 2
YOUR_DISK_ID.j /usr/src ffs rw,softdep,noatime,nodev,nosuid 1 2
YOUR_DISK_ID.e /var ffs rw,softdep,noatime,nodev,nosuid 1 2/etc/fstabA number of guides also suggest making changes in /etc/sysctl.conf to improve the performance of your computer by setting certain kernel options at start up, such as shared memory (kern.shiminfo.shmmax) etc. I couldn't find any evidence that this actually made any difference in my case.
Comments
While I could find lots of descriptions of which options exist, and what each option is in the man pages, I couldn't find any guides (outside of specific database tuning) that suggested any specific values, and more importantly how to calculate those better values. Also it didn't explain why the system would not automatically choose the best values - why would the defaults restrict that, assuming there was no related security risk? While this tuning appears in a number of OpenBSD guides, I can't find a good original source for suggesting improved values. If you have one, please let me know.
The one performance tweak I can think of that's worth doing is enabling multi-threading (SMT) if your processor supports it. Most do, but this laptop with its humble Celeron N3060, doesn't have that feature (called hyper-threading in Intel speak). This is disabled by default because of the potential security issues.
The only other things that are probably relevant would be enabling audio and video recording if you want to do that. In which case your sysctl.conf could look like:
hw.smt=1 # Turn on multi-threading
kern.audio.record=1
kern.video.record=1/etc/sysctl.confI tried all kinds of different variations for shared memory etc, but couldn't get a measurable change in the benchmark I'm using; Browserbench's SpeeDOMeter 2. It's probably not a great test in many ways, but it represents this laptop's hardest challenge; is browsing the modern web. I couldn't get a score of better than 10.7 with any combination of settings. For comparison my Moto G8 Android phone gets 25, and my 2012 MacBook Pro gets 89.
Power Management
To enable the power management you need to enable and start the Advance Power Management daemon apmd, which can be done with:
# rcctl enable apmd
# rcctl set apmd flags -A
# rcctl start apmdThe -A flag setting it to automatic mode.
Comments
An alternative to the above is to use obsdfreqd to manage the CPU when plugged on, or on battery, and use that to adjust the performance more dynamically based on the system's demands. First you have to install it, then you can use it along with apmd, but set to one of the manual options (like high, -H)
pkg_add obsdfreqd
rcctl enable apmd
rcctl set apmd flags -H
rcctl start apmd
rcctl enable obsdfreqd
rcctl start obsdfreqdHibernation, Sleep etc.
What works is the screen going black when you close the lid, other than that I've not had a lot of luck.
The apm -z command does seem to suspend the laptop, the white power LED starts to flash after a minute and I can close the lid. If I then open the lid again the screen comes back on showing what was previously there on suspension - but then mostly completely locks up, and doesn't respond to any keyboard inputs any more. Once or twice it comes back and then you can interact a bit with a pre-existing Xterm, but not all commands work, often giving a response like input output error, and other shortcuts in CWM, like creating a new terminal don't work. Also if you try to run apm -z again, nothing happens.
Hibernation (apm -Z) isn't any better. The screen goes blank, but the power LED remains on, and then I can't wake it again and the screen remains black with the white power LED glowing continuously. I have to power the laptop off with a long power press.
I had these same problems when I tried suspending and hibernating from a non-X console (e.g. Ctrl+Alt+F1), so I'm not sure it's a pure X Window issue.
None of these have caused a kernel panic that results in me landing at the ddb(1) interface to investigate further. I'm not familiar enough with OpenBSD to figure out how do a post mortem on thes issues, or at least not enough to turn it into a useful bug report2.
Screen Brightness Control
Last change that I'm considering part of the non-personalised set-up is being able to adjust the screen brightness, as the initial value is painful on both the eyes and battery life.
The good news is that it can be easily adjusted from the command line with either xbacklight or wsconsctl, both the commands below set the screen to 50% brightness:
xbacklight -set 50
or
wsconsctl display.brightness=50
The only difference is that xbacklight doesn't require root privileges, and has a fade between brightness levels.
The laptop has a row of shortcut/Function keys on which F2 is brightness down, and F3 is brightness up - but (as with the previous Linux install) these don't work without any configuration. Like last time I'll use xbindkeys (which you have to install) to map these to those actions. Strangely the brightness up/down keys trigger the same keycode, and don't have a symbol (when tested with xbindkeys -k), so as a work around both are bound to brightness down (10%) and shift+the key brings the brightness up by 10%. Create the .xbindkeys config file like this, then start xbindkeys and check it works.
#BrightnessDown
"xbacklight -10"
m:0x0 + c:171
# This doesn't map to the following, but does on linux
# XF86MonBrightnessDown
#BrightnessUp
"xbacklight +10"
m:0x1 + c:68
Shift + F2
# XF86MonBrightnessUp~/.xbindkeysThen when you start xbindkeys under X as part of your .Xsession (see below) you can use those keys.
Comments
It's a little strange that both the up and down brightness give the following response to xbindkeys -k:
m:0x0 + c:171
NoSymbolThe volume up and down function keys worked without any configuration needed, and when tested response with:
m:0x0 + c:174
XF86AudioLowerVolumePreviously under Debian, F2 would register the symbol XF86MonBrightnessDown and F3 XF86MonBrightnessUp. I wonder why it doesn't for brightness when it does for audio, and if it did, if the brightness adjust would work straight away.
Customisation
Up to now everything has been general improvements and setting up of the laptop. From now on it gets more personal, and you will probably have different opinions on how you want to do things. You do you, but if you're interested this is what I've settled on for now3. My OpenBSD dotfiles are collected in this respository in the OpenBSD folder, if you want to see them in all their confused glory. (They will probably update with time, and this post won't keep up with the changes, so expect some mis-match.)
I'm also a heavy Emacs user, but the configuration of that is completely separate and not addressed here.
Essential Programs
This is my personal list of minimum programs I needed:
- git
- colorls - the default
lsin OpenBSD doesn't colour different types of files, and I find that really useful. - xpdf
- htop
- yank
- xbindkeys - see above.
- Firefox - or Chrome(ium) if you prefer. I tried both and didn't notice much difference, both ran pretty slowly, even with uBlock origin and other ad blockers installed.
- w3m - A simpler web browser you can run from the command line that doesn't support CSS and JavaScript, but does support images4 (if you install that versions,
pkg_addgives you the choice). - feh - For viewing images, also useful to set a background image if that's your thing.
- Emacs - I choose the GTK2 version when prompted, I could have picked GTK3 instead, but I'm not sure practically what the difference is when running it in CWM.
- Hunspell - This is my preferred spell check program, and I use that in Emacs as well. follow up with adding the package
mozilla-dicts-cafor the dictionaries (which in my case only installed 'en-GB', I guess it's based on your localisation settings?).
To set Firefox as the default browser to handle links you have to set it with xdg-settings as follows:
xdg-settings set default-web-browser firefox.desktop
Then when you click a link in other applications, like Emacs, it will open it with your choice.
X Setup
Xenodm is the X display manager, and the first set of chance to set some X based options. I commented out, with #, the line that starts the xconsole as I wasn't using it, and then added the following entries to the bottom of the file to adjust the initial screen brightness, make the keyboard match the UK keyboard on the laptop and turn the bell off. This applies to all users.
....
# Otherwise it burns our eyes
xbacklight -set 50
# To match layout at login time
setxkbmap -layout gb
# Turn off the audio beep
xset b off/etc/X11/xenodm/Xsetup_0 (partial)The .xsession options are run when you login, and are personal to you. It ends by starting the CWM window manager, which I picked over FVWM and is part of the base install. I found it a little easier to use with the keyboard and not having the title bars helps on the small screen.
# UTF-8 Everywhere
export LANG=en_GB.UTF-8
# Location of ksh config
export ENV=$HOME/.kshrc
# Add .Xresources for appearnce changes
xrdb -merge $HOME/.Xresources
# Set background colour
xsetroot -solid dimgrey
# Turn off system beep
xset b off
# Turn down the inital screenbrightness (%)
xbacklight -set 50
# set custom bindings in ~/.xbindkeysrc
xbindkeys
# Make caps lock control.
setxkbmap -option ctrl:nocaps
# Start CWM
exec cwm~/.xsessionTalking of which…
CWM / Window Manager
The main changes here are re-mapping most of the keys not to use Control, but instead the Window/Super key (referred to as '4' in the bindings), as it prevents clashes with common Emacs keybindings. The other thing is to make room for a simple terminal based status bar across the top of the screen, called a termbar. The source is just a shell script, and if you're curious you can find it in the code storing these dotfiles. Lastly are the most used programs to launch from the command menu.
# Appeareance and termbar spacing
snapdist 4
sticky yes
gap 24 0 0 0
ignore "termbar"
autogroup 0 "termbar,termbar"
fontname "Courier:pixelsize=18:bold"
color menubg "orange"
color activeborder "orange"
# Mouse bindings
unbind-mouse all
bind-mouse 4-1 window-move
bind-mouse 4-2 window-resize
bind-mouse 4S-1 window-resize
# Keyboard bindings
# 4 is the Windows/Super key, that doesn't conflict with much
# especially Emacs
unbind-key all
# Window Navigation
bind-key M-Tab window-cycle
bind-key MS-Tab window-rcycle
# Window Geometry
# "ijkl" is like the right hand side WASD on UK Keyboards
# and I have no vi(m) muscle memory
bind-key 4-l window-move-right-big
bind-key 4-j window-move-left-big
bind-key 4-i window-move-up-big
bind-key 4-k window-move-down-big
bind-key 4S-l window-move-right
bind-key 4S-j window-move-left
bind-key 4S-i window-move-up
bind-key 4S-k window-move-down
bind-key 4C-l window-resize-right-big
bind-key 4C-j window-resize-left-big
bind-key 4C-i window-resize-up-big
bind-key 4C-k window-resize-down-big
# Window Position
bind-key 4-Right window-snap-right
bind-key 4-Left window-snap-left
bind-key 4-f window-maximize # Honors gaps
# Window Order
bind-key 4-Down window-lower
bind-key 4-Up window-raise
# Window Control
bind-key 4-x window-close
# There's sadly no move to right-half screen
# option, but if you vtile (which uses left half)
# and then pick another vmaximize it's only
# a couple of keystrokes.
bind-key 4-v window-vmaximize
bind-key 4-h window-vtile
# Group Navigation
bind-key 4-Tab group-cycle
bind-key 4S-Tab group-rcycle
bind-key 4-1 group-only-1
bind-key 4-2 group-only-2
bind-key 4-3 group-only-3
bind-key 4-4 group-only-4
bind-key 4S-1 window-movetogroup-1
bind-key 4S-2 window-movetogroup-2
bind-key 4S-3 window-movetogroup-3
bind-key 4S-4 window-movetogroup-4
# Command functions
bind-key 4-space menu-cmd
bind-key 4-slash menu-exec
bind-key 4-Return terminal
bind-key 4S-slash menu-window
bind-key 4S-r restart
bind-key 4S-q quit
# Command window entries
command emacs emacs "-fh --name=Emacs"
command firefox firefox
command w3m xterm "-e w3m https://www.duckduckgo.com"~/.cwmrcXresources
This is much better explained in other places, but I'll include it for completeness in case it helps anyone solve a specific issue. The Arch Wiki has a good article on the Xresources config, as well as XTerm. Speaking of which I found this XTerm Introduction and the Hidden gems of XTerm articles interesting, as someone who hasn't really used XTerm much before.
For a colour scheme it's easiest to pick one from a collection like the Xresource Themes repo and can be loaded from a separate file with the #include statement.
! Always start in unicode
XTerm*utf8: true
Xft.antialias: true
! Lines of output that you can scroll back over
XTerm*saveLines: 4096
! Turn the scrollbar on, and put it on the right
XTerm*scrollBar: true
XTerm*rightScrollBar: true
! Only select text
XTerm*highlightSelection: true
! Remove trailing spaces
XTerm*trimSelection: true
! and dont include a trailing newline in the selection!
XTerm*cutNewline: false
! Something copied from the internet to change
! what XTerm considers "word delimiters" more useful
XTerm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48
! select word on two clicks
XTerm*on2Clicks: word
! select whole line on three clicks
XTerm*on3Clicks: line
! set TERM env variable to use 256 colors
XTerm*termName: XTerm-256color
! make alt key work normally
XTerm*vt100.metaSendsEscape: true
! Merge in a nice theme
#include ".dotfiles/resources/base16-gruvbox-dark-pale-256.Xresources"
! Select a nicer font and slightly larger than the default
XTerm*faceName: Courier:size=8:
! Make pasting in things like Firefox easier:
XTerm*selectToClipboard: true
! Adds more 'usual' copy and paste
! functionality with Ctrl+Shift+C/V
! which works better on trackpads without good middle mouse options.
XTerm*VT100.Translations: #override \n\
Ctrl Shift <Key>V: insert-selection(CLIPBOARD) \n\
Ctrl Shift <Key>C: copy-selection(CLIPBOARD)~/.XresourcesIn the above I specify the font 'Courier' that comes pre-installed and is a nice font. If you spend a lot of time looking at a monospaced font I think you can treat yourself to a nicer one and I very much enjoy Calling Code by Dharma type, but it's not free (in any sense of the word).
To install a custom font, copy the .ttf files into ~/.fonts/ and then run:
fc-cache
To find existing fonts, in this case filtered by mono-spaced regular fonts, that you can run:
fc-list :mono:regular
Then test it in XTerm by launching a new instance, in this case with Courier
xterm -fa "Courier"
KSH
In keeping with trying something new I've stuck with the ksh shell that comes in the base install (I have to admit normally my preferred interactive shell is fish, and it is available on OpenBSD too).
Make sure that your KSH preferences in .kshrc are included in the .profile file with:
export ENV=$HOME/.kshrc
and then it will include the following every time you launch a new instance of the shell.
export EDITOR=mg
export LANG=en_GB.UTF-8
HISTFILE=$HOME/.ksh_history
HISTSIZE=2000
# Emacs mode
set -o emacs
# use colorls if it's installed, plain old ls otherwise
if command -v colorls > /dev/null ; then
LS='colorls'
else
LS='ls'
fi
alias ls="$LS -FHh"
alias ll='ls -l'
alias la='ls -lA'
alias ..='cd ..'
alias ...='cd ...'
alias mkdir='mkdir -p'
alias df='df -h'
alias du='du -ch'
alias goodnight='shutdown -p now'
# Easily copy text to the X Clipboard
alias clip='yank | xsel -b'
# Adjust the prompt, red when root.
_XTERM_TITLE='\[\033]0;\u@\h:\w\007\]'
_PS1_CLEAR='\[\033[0m\]'
_PS1_BLUE='\[\033[34m\]'
case "$(id -u)" in
0) _PS1_COLOR='\[\033[1;31m\]' ;;
*) _PS1_COLOR='\[\034[32m\]' ;;
esac
PS1='$_XTERM_TITLE\A $_PS1_COLOR\u@\h$_PS1_CLEAR:$_PS1_BLUE\w$_PS1_COLOR\$$_PS1_CLEAR '~/.kshrcConclusion
The main issue at the moment is the lack of working suspend and hibernate, something I should spend a bit more time trying to understand how to debug. Other than that it seems to work pretty well and perhaps I'll take the leap and install it on another laptop that I use more regularly.
Yes, that's a joke. I'm aware that you can also use Emacs to edit text. Somehow. I think. I'm almost certain saw someone do it once somewhere. ↩
Not that anyone anywhere should spend their valuable time figuring out why this cheap laptop isn't suspending properly. ↩