ThinkPad T60 and OpenBSD Part 3

Published on by Negate This #thinkpad #openbsd #technology


It’s the summer time! School’s out, so classes are as well. I was mostly using my ThinkPad T60 for taking notes in classes, so I haven’t used it extensively in a couple of months. I have started to use it again, though, and I’ve made quite a bit of changes since the last time I made a post.

DWM and co.

My last post about my ThinkPad T60 and OpenBSD involved me setting up FVWM, but I’ve since made the switch to DWM and I’m enjoying it quite a bit. DWM is a program made by the suckless community, and as such it is necessary to compile it oneself and set any options pre-compilation. Luckily, DWM is available in the OpenBSD ports tree and is pledged. Instructions on fetching and using the ports tree are located at the official OpenBSD website.

Once you’ve fetched the ports tree, following the instructions below should be enough to build and install DWM.

$ cd /usr/ports/x11/dwm
# make install

That will successfully build DWM on OpenBSD with the appropriate patches. Just for continuity’s sake, I also installed st, the suckless terminal emulator, and slstatus, the suckless status bar. st is available in the ports tree as well, at /usr/ports/x11/st, and can be installed the same way as DWM.

As far as I can tell, slstatus is not in the ports tree, so you’ll have to compile it yourself. Doing so is fairly easy, though:

$ git clone git://git.suckless.org/slstatus
$ cd slstatus

Now edit config.h with your desired configuration. Personally, I’ve set it up as follows:

static const struct arg args[] = {
    /* function format          argument */
    { datetime, "%s",           "%a %Y-%m-%d %H:%M |" },
    { cpu_perc, " cpu: %s%% |",  NULL },
    { ram_used, " mem: %s |",  NULL},
    { battery_perc, " bat: %s%%", NULL },
};

Now, you can build and install it easily:

# make install

Now, just add these two lines to your ~/.xsession so that DWM and slstatus will start on login.

slstatus &
exec dwm

For anyone new to DWM, here’s a small rundown on how to navigate it, assuming you didn’t set up any custom configuration. Or, if you’d like, you can read the official DWM tutorial.

Alt+P will open dmenu. You can type a command here and it’ll run. For example, pressing Alt+P, typing “firefox” and pressing Enter will open Firefox.

At the top left, you’ll see numbers 1-9. These are different “tabs” and each will hold your different windows. I mostly only ever use tab 1, and the rest of the tab stay blank besides tab 9. You can switch between the tabs by pressing Alt+number, where the number corresponds to the tab you want to navigate to. When opening a program in dmenu, it will open in the tab you are currently on. If you are using the default configuration, Firefox will always open on tab 9 no matter what tab you happen to be on.

Alt+Shift+Enter will open an instance of st in whatever tab you are currently on.

DWM has 3 different modes, and you can tell which mode you are on by looking at the symbol on the right side of the 1-9 tab list.

[]= means tiling mode. All windows will tile. Activated by default or by Alt+T

><> means floating mode. Windows will float instead of tile. Activated by Alt+F

[1] means monocle mode. This will focus on a window. Activated by Alt+M

When you have more than one window on your screen at a time, these are different ways you can manipulate windows:

Alt+J will switch you between the different windows on your screen.

Alt+H and Alt+J will resize your windows.

Alt+Enter will switch around the windows on your screen.

Alt+Shift+Number will move the window you are on onto a different tab

These are usually enough to get me comfortably by when using DWM in my day-to-day.

xscreensaver instead of xlock + xidle

The common combo for locking your screen after a set amount of time is xlock + xidle, a combo which Solene coincidentally talked about on July 30th, the day I began to write this post.

I opted to use xscreensaver instead, mostly for the reasons the developer themselves have listed.

Setting it up is fairly easy. xscreensaver is available as an OpenBSD package, so installing it involves just running

# pkg_add -i xscreensaver

This also installs xscreensaver-demo, which is a GUI where you can configure all your options for xscreensaver. Running it should also generate the corresponding ~/.xscreensaver configuration file.

The ~/.xscreensaver file should give you a myriad of options. The ones I particularly care about are:

timeout:    0:05:00
cycle:  0:05:00
lock:   True
lockTimeout:    0:03:00
passwdTimeout:  0:00:30
...
splash: False
...
mode:   blank
...

The splash being set to False is a necessity for me, as I don’t want to see the splash on every boot. Also, I like the mode set to blank because the screensaver options are a bit too “corny” for me, and fading to black is fine enough for me, although I do sometimes get the urge to use the pipes screensaver for nostalgia reasons!

As for the other options, you should set that to whatever values you feel are good for yourself. I think activating the screensaver after 5 minutes then locking the screen after another 3 minutes is acceptable for my use.

Now, to make sure xscreensaver starts on boot, just throw this into your ~/.xsession file:

xscreensaver-command -exit 
xscreensaver &

You should also make sure that xscreensaver locks your screen when your computer suspends itself. Luckily, if you have apm installed, this is fairly trivial on OpenBSD. Just create the /etc/apm/suspend file as root and put this into it:

#!/bin/sh
xscreensaver-command -lock

Make sure to also run:

# chmod +x /etc/apm/suspend

This makes the file executable so that it’ll successfully run when your system suspends, locking your screen.

herbe for notifications

I started using a program named herbe for daemon-less notifications.

It doesn’t do any more than it needs to - it displays a rectangle at the top right of the screen with a title and body that can be dismissed by left-clicking it.

In my last post, I installed the command line Telegram client, tg. It allows for setting a custom notification command, which means one can easily integrate herbe in order to receive notifications when tg is open and you get a new message. All that you’d need to do is add the following line into your ~/.config/tg/conf.py file:

NOTIFY_CMD = "/usr/local/bin/herbe {title} {subtitle} {msg}"

Perfect! And for anyone that’s been using notify-send in their scripts to send notifications to the desktop, there’s a handy script that hijacks any calls to notify-send and sends them to herbe instead.

Conclusion

These different changes have given me a very usable desktop experience that works surprisingly well for a 15-year-old laptop. I think I say the age of this ThinkPad T60 every time I write about it, but it’s because I seriously can’t believe how much use one can get out of something that is practically useless by modern mainstream computing standards. Get the most out of the things you have! It’s a fun process.