May 2, 2016

OpenBSD: After install

/etc/login.conf

First, make sure you belong to the class (not group) staff:

# user mod -L staff pau

Then give a bit more of RAM to programs


#
# Staff have fewer restrictions and can login even when nologins are set.
#
staff:\
#:datasize-cur=1536M:\
:datasize-cur=2048M:\
:datasize-max=infinity:\
:maxproc-max=512:\
:maxproc-cur=256:\
:ignorenologin:\
:requirehome@:\
:tc=default:

Allow mic to record

This has been disabled from 6.2 (https://www.zdnet.com/article/audio-recording-is-now-disabled-by-default-in-openbsd/).

To get it back, simply run

# echo kern.audio.record=1 >> /etc/sysctl.conf # set at boot

Secure screen after suspending

Use xdm: Since you do not want to leave a terminal open, do not start X with startx. This would leave open that terminal and launch X on another one. Since you are using xdm, you need a .xsession file instead of a .xinitrc. My .xsession file looks like

xmodmap -e "keycode 22 = BackSpace BackSpace BackSpace BackSpace BackSpace BackSpace"
pkill xidle
xidle -delay 5 -sw -program "/usr/X11R6/bin/xlock -mode blank" -timeout 90 &
qiv -zr $HOME/escriptori/Galicia/*
xset -b
cwm -c /home/pau/fitx_confg/cwm/cwmrc

The first line cancels the function Zap of X, which means that nobody can interrupt your X session by pressing CTRL+Alt+Backspace. xidle is necessary to launch the screensaver via xlock

Create /etc/apm/suspend and make it executable:


$ cat /etc/apm/suspend
#!/bin/sh
pkill -USR1 xidle

Make sure apm is running everytime after boot. If it is not, while your laptop will suspend, the script suspend will not be executed, and the screen will not be locked. To test if apmd is running, type zzz from the terminal. A message like zzz: cannot connect to apmd: No such file or directory Will tell you that your apmd is NOT running.

To have apmd run after boot, add a flag to rc.conf.local:

$ cat /etc/rc.conf.local
sshd_flags=NO
dbus_enable=YES
apmd_flags="-A"
xenodm_flags="YES"
mixerctl inputs.spkr.mute=on

Check your battery

OpenBSD will not shutdown your laptop if you’re running out of battery. I have this script in my bin and I have root calling it every one minute in /etc/rc.local.


$ cat bin/CheckBattery.sh
#!/bin/sh

# Check battery with apm and shutdown the laptop if
# below 30', more exactly, 5' later.
#
# This needs root to add the line
#
# /usr/local/bin/gnuwatch -n 60 /home/pau/bin/CheckBattery.sh
#
# to /etc/rc.local
#
# # A reminder on the operator:
# -eq # equal
# -ne # not equal
# -lt # less than
# -le # less than or equal
# -gt # greater than
# -ge # greater than or equal

time=`apm | grep minutes | awk '{print $6}'`

# If apm shows 60 or more minutes, don't do anything

if apm | grep -q "not connected" ; then
# A/C adapter connected, don't do anything
else
# A/C adapter not connected, check time
if [ "$time" -ge "60" ] ; then
:
fi
fi

# If apm shows 30 or less minutes, wall it

if apm | grep -q "not connected" ; then
# A/C adapter connected, don't do anything
else
# A/C adapter not connected, check time
if [ "$time" -le "60" ] ; then
echo " Half an hour or less of battery. " | wall
fi
fi

# If less or equal than half an hour, warn to save work,
# sleep for 5' and then shutdown, with a short sleep of 5''.

if apm | grep -q "not connected" ; then
# A/C adapter connected, don't do anything
else
if [ "$time" -le "30" ] ; then
echo " ---> SAVE YOUR STUFF - Shutting down in 5 minutes <--- " | wall sleep 300 echo " Shutting down... " | wall sleep 5 halt -p fi fi

Add to /etc/rc.local this line

/usr/local/bin/gnuwatch -n 60 /home/pau/bin/CheckBattery.sh

Customize xdm

You can for instance change the background by adding an image and using qiv. For this, make a directory to store background images, e.g. /usr/local/share/backgrounds/pau and add images there. Then

# vim /etc/X11/xenodm/Xsetup_0

And change the console line to

#xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed -exitOnFail
/usr/local/bin/qiv -zr /usr/local/share/backgrounds/pau/*

firefox

In about:config

Set these two options:

gfx.xrender.enabled true
layers.acceleration.force-enabled true