LinkedIn Sourceforge Twitter

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

My prefered Desktop environment for OpenBSD

Posted on 2016-12-02 15:46:00 from Vincent in Open Bsd

In my previous post, I've explained how easy it is to install a desktop environment on OpenBSD. I've used the Lumina Desktop Environment because it's a complete desktop environment (file manager, panel, task bar, ...). Moreover Lumina is developed on BSD systems (FreeBSD), it's new and it's a promising desktop environment.

In this post I'll explain how and why I'm using Openbox for my desktops, why Openbox is my preferred window manager, and I will share some tips.


1. Motivations

Let me first explain why I'm mainly using Openbox on my different OpenBSD desktops and laptops.

It was more than 5 years ago, I've decided to get rid of my Linux based system for my desktops and laptops. The decision was to move to OpenBSD since I was using it mainly for network and server related activities.

At that time XFCE was a great choice. This environment was "familiar" to me and very stable on OpenBSD. But release after release the number of features not working on OpenBSD dangerously increased. On one side the XFCE developers were taking less and less care of BSD and on the other hands very few persons were willing to adapt XFCE to BSD. You can measure the problematic by reading the xfce's forum of 2011.

At that time KDE was not an option (too much features not working on OpenBSD); and I thought that the last option would be to use Gnome. For personal reasons, gnome is not my preferred desktop environment, so I've looked for others systems: Enlightment, Fluxbox, Openbox, ... .

Finally it came to me that (in 2011), because the increasing gap between Linux and BSD systems, it would be better to have a simple window manager and to add to it the tools I need (which are perfectly compatible with OpenBSD). So, I forget the idea to have the "all in one box" system like we have with KDE, Gnome, XFCE, ...

In one sense, I have to forget the "big actors" and be prepared to forget my habits in order to be able to begin with new systems more adapted to my preferred OS.

Those ideas are now old, but it sounds that the problematic is still there. Check here the feedback (in November 2016) of a port's maintainer concerning the increasing difficulties to maintain Gnome.

2. Simple desktop alternatives

Ready to investigate the simple window manager, the first choice to make is to decide between "traditional" window manager and tiling window manager. Personally, I've decided to stay in the "traditional" window manager. This is pure personal choice and everyone should test both solutions before deciding which one fit his needs.

To evaluate the tiling window manager, I recommend to give a try to cwm. This is the default window manager in OpenBSD, it's present in the base system. i3 is an another good tiling window manager to evaluate.

On the "traditional" window manager I've tested Fluxbox and Openbox. Both are quite comparable, please give it a trial to both of them to decide which one best fit your needs.

For me, Openbox is much better; moreover, I don't need the features proposed by Fluxbox like tabbing. And the Fluxbox's panel bar does not offer me all the flexibility I'm looking for. After couple of weeks, I was using Fluxbox with PyPanel and/or Tint2.

Maybe because of wrong setup on my side, but Fluxbox was crashing a couple of times. Having your desktop environment crashing is very frustrating because you loose all what you are doing.
On the other hands, I've never had a crash of Openbox in the last years.

One very nice feature of Openbox is the dynamic menus, what they called the "pipe menus". I'll provide some samples here bellow. But in short it means that you can build, on the flight, the content of the menus. This is a features I'm using a lot and don't understand why it's so rare in other desktop environments.

After this period of test (took +- 6 months), I've decided that Openbox will be my final choice. This decision is dated on 2013.
I don't think that, if I redo the same exercise today my final decision will be different.

The only possible exception is Lumina. But Lumina is still very young and most annoyingly, for me, it runs on top of Fluxbox. So my fear to loose what I was doing (a crash) keep me away from Lumina.
If I'm correctly informed, the developers of Lumina are willing to move away from Fluxbox (have they crash problems too ??). Anyhow, before they are moving to something else, I keep my rock stable Openbox window manager.

3. Let's adapt Openbox to our needs

As said Openbox is a lite windows manager. It comes with a wonderful menu's system, but you don't have a task bar, neither a panel bar, neither icons on your desktop.

So let's see how we can add those "usual" features. They are, at least, features requested by a lambda user. I remind that my kids have all OpenBSD on their desk and nothing else.

I'll first propose you to have a nice looking panel/task bar on your screen (with fade and shadows). Then I will propose you have a desktop manager (manage the icons on your desktop), and finally I will explain you how to build menus on Openbox

3.1 The taskbar / panel

Switching between windows by doing "alt-tab" is not always simple.

After having tested several taskbar and panel, I recommend you to check 2 good ones: PyPanel and Tint2.

Pypanel is really basic and simple. It's mainly written in python, so it can be easily adapted and improved.
Tint2 is very nice looking, but it's written in C and much less simple, at least for me, to adapt.

Please note that, PyPanel is one of the rare application which does not have his OpenBSD ports. Fortunately the steps are not so complex to install it.

You have to, first, install some pre-requisites:

doas pkg_add py-pip
doas pip2.7 install python-xlib

Once that done, you just have to download, untar, build and install the package:

ftp -o PyPanel.tar.gz https://sourceforge.net/projects/pypanel/files/latest/download
tar -xzvf PyPanel.tar.gz
cd PyPanel-2.4
sed -i.bkp 's_/usr/bin/imlib2-config_/usr/local/bin/imlib2-config_' setup.py
python2.7 setup.py build
% doas python2.7 setup.py install

As you can see, we have to update the setup.py file and replace /usr/bin/imlib2-config to /usr/local/bin/imlib2-config which is more "bsd" compliant.

For Tint2, just do as usual:

pkg_add tint2

Both are great, but their features are not exactly the same. PyPanel is a panel bar and also a taskbar. Tint2 is just a panel bar.

Despite PyPanel is quite a basic system I've decided to use it. Mainly because it's written in Python, thus easy to adapt. So easy that after couple of weeks, I've made lot of changes in PyPanel !!!.
So much that I will not impose my idea to the creator. Instead I've rename it: sipypax for Simple Python Panel for X windows.

To give you an idea, the current diff output says that 708 lines have been changed or added by sipypax, compared to the 957 line PyPanel has. Thus sipypax is major change, but it keep the main concepts and ideas of PyPanel.

I'll not goes into the details of sipypax in this post, I'll do it in the future.

Anyhow, the source code is available here

Some screenshots:

sipypax on the desktop:

2nd virtual desktop:

To install sipypax, if not yet installed, you just have to install some pre-requisites:

doas pkg_add py-xdg xdg-utils
doas pkg_add py-pip
doas pip2.7 install python-xlib

Then, you just have to build and install it.

ftp -o sipypas.tgz https://sourceforge.net/projects/sipypax/files/latest/download
tar -xzvf sipypax.tgz
cd sipypax*
python2.7 setup.py build
doas python2.7 setup.py install

As said, I'll later dedicate a post on this blog for this small peace of code, how to use it, how to configure it, ...

3.2 Integrate sipypax into Openbox

Now that we have a nice looking panel / taskbar, let' see how to start all of this with Openbox.

Openbox foresee a special script called "autostart.sh" for our purpose. You can build it in ~/.config/openbox

Mine is looking like this:

export DE=gnome   #useful for icons of some applicaitons
xcompmgr -cCfF &  #composit manager
sipypax.sh > /tmp/sipypax.log 2>&1 &   #our simple Python Panel for X

(For sure, you can replace the last line by PyPanel or Tint2 or ...)

As you see I've added a extra command: xcompmgr. This is a compositing manager offering you very nice looking behaviour on your desktop.

The option I propose will allow you to have soft shadows and fade effects.

3.3 Having a desktop manager

For those willing to have icons on the desktops (shortcuts, ...), you have to install a dedicated tool for that.

I propose you to install pcmanfm. This tools will do this task very well, and he will also become your file manager.

To install it, just type the usual command:

pkg_add pcmanfm

To have it started automatically, you can add the following command in your ~/.local/openbox/autostart.sh file:

/usr/local/bin/pcmanfm --desktop &     #to replace the Openbox desktop background

To get your menus of Openbox, do not forget to mention it to pcmanfm by launching the configuration GUI called: pcmandfm --desktop-pref. Verify tha the check box in the 3rd panel is selected. It says "Show menus provided by window managers when desktop is clicked"

We will see later how link this script to your Openbox menus. So a simple click will launch the pcmanfm preference screens.

On this desktop manager you can have standard files and executable. For a file, you just have to copy it to the folder ~/Desktop. For executable you have to build or to copy a .desktop file in your ~/Desktop folder. To better understand the specifications of such file, I let you check the freedesktop web site

3.4 Build our standard Openbox menus

I will propose you a Python script to build those menus automatically.

Basically the idea is to write automatically the file called menu.xml. You can find it in your ~/.local/openbox folder. Several tools already exist but none were matching my needs, so I've written one.

The script I propose builds for you a default structure on which it will add all applications we can find on your machine.

The script looks for .desktop files and add them in your menu with name and icons found in each .desktop file.

The source code is available here
(please note that this tool needs py-xdg)

I would internationalize this script so that non-english persons will see the menus in their own languages. I'll do it when I will have the time for it. But if someone is ready for help, it's welcome.

Please note this this script generates "Pipe menus". But I'll describe most of them here bellow.

Just launch this script every time you install a new package on your system. Or, for lambda users, just execute this script is every boot of your system (it could be in .xinitrc for example)

If you are interested to have more details, I can foresee a dedicated post for this tool in the future. But for today, let's move on with Openbox.

3.5 Pipe menus of Openbox

Openbox comes with what they call: "pipe menus". A feature allowing you to dynamically build your menus. I'll share with you some practical usage I'm doing with this.

You can find some explanations on the Openbox - pipe menus

You can also find list of possible usage on the Openbox - pipe examples

In short, the process is composed on 2 steps:

1) You just have to add, in your menu.xml file (located in ~/.config/openbox), the following element:

<menu id="ID" label="TITLE" execute="COMMAND" />

You can place it where you want in your menu.xml file.

2) Your "COMMAND" script has to return a valid xml file with a layout like this:

<openbox_pipe_menu>
  <item label="LABEL">
    ACTIONS
  </item>
</openbox_pipe_menu>

Let me share with you some samples.
You will immediately understand how this is easy and powerful.

3.5.1 Battery monitoring

Let's start with a simple one: display the battery's status.

Thus, in my menu.xml file, I add the following:

<menu id="battery-menu" label="Battery status"  execute="~/.config/openbox/battery.sh" />

and my script is doing this:

#!/bin/ksh

val=$(apm -l)
duration=$(apm -m)
echo "<openbox_pipe_menu>"
echo "<item label="Battery is $val% full, duration: $duration minutes">
          </item>"
echo "</openbox_pipe_menu>"

Thus, every time you will goes to the battery menu, the menu will opens with the message saying the status of the battery. The script is executed every time you goes on that menu with your mouse. (we can also go to it via keyboard, details are here bellow)

3.5.2 NFS status

Here, I want to inform the user if the NFS drives are mounted

<menu id="NFS-status" label="NFS status"  execute="~/.config/openbox/nfs_status.sh" />

And my script is the following:

#!/bin/sh

RES=`mount -t nfs | wc -l|sed -e 's/ //g'`

echo "<openbox_pipe_menu>"
if [ "$RES" = "0" ]; then
 echo "<item label="NFS not mounted">"
else
 echo "<item label="$RES NFS mounted">"
fi
echo "    </item>"
echo "</openbox_pipe_menu>"

Thus this menu shows me how much NFS drives are mounted.

In the menu.xml, I also add the possibility for the user, to mount/umount the nfs drives with a simple click. To do that I'm adding the following in the menu.xml file (this is not a pipe menu):

 <item label="NFS toggle u/mount" icon="">
    <action name="Execute">
      <command>~/.config/openbox/toggle_mount_nas.sh</command>
    </action>
</item>

And the script is doing:

#!/bin/sh

if [ ! -d /net/nas/share ]; then
   doas mount -a -t nfs
else
   doas umount -a -t nfs
fi

(your /etc/doas.conf file must allow the user to perform such command)

3.5.3 Network connections

I have a script dedicated to setup my network connections and to scan for "open wifi". It allows me to connect my wifi interface to any pre-configured hostspots. I can also, by a simple click, list all Hostspots around me and see which one are "open". For those which are "open", I can simply click on it to be connected.

This is not very complicated to build, but this can be the subject for post by itself. So, let me explain this in a future post if your are interested.

I just mention it, because it show how powerful this concept of Pipe menus is.

3.6 The keyboard shortcuts

To be complete concerning Openbox, I must mention the shortcut possibilities.

Here again the possibilities are huge. I've not yet explored all of them.

If you are interested in that topic, just read the Openbox - bindings page.

Those parameters must be consolidated in the "rc.xml" file you can find in your ~/.config/openbox folder.

In short, Openbox allows you to associate actions with keys. But it will also allow you associate "keys chains" to actions. Useful to associate the "up" and "down" keys to different actions, depending on the key chains sequence you have defined.

You can also define mouse bindings to define specific actions on your systems

Here after 3 very useful settings:

<keybaord>
...
  <keybind key="A-F1">
    <action name="Execute">
      <command>xterm -geometry 100x20</command>
    </action>
  </keybind>
  <keybind key="W-r">
    <action name="Reconfigure"/>
  </keybind>
  <keybind key="W-space">
    <action name="ShowMenu">
      <menu>root-menu</menu>
    </action>
  </keybind>
...
</keybaord>

The first one associate xterm to the key combination of "Alt" and "F1".
The second one allows your to reinitialise Openbox (reload menu.xml, rc.xml, ...) by hitting "windows key" and "r".
The third on allows you to display the Openbox menus by hitting "windows key" and "space" keys of your keyboard. The menu will be displayed where your mouse is located.

Also in the <keyboard> section, the following commands allow you to increase or decrease the speakers of your machine. This is useful in case of OpenBSD does not react correctly to the existing sound control buttons.

<keybind key="W-Up">
  <action name="Execute">
    <command>mixerctl outputs.master=+20</command>
  </action>
</keybind>
<keybind key="W-Down">
  <action name="Execute">
    <command>mixerctl outputs.master=-20</command>
  </action>
</keybind>

Just hit the "windows key" and the "up" or "down" arrows to adjust the sound.

As you can see, here too, the possibilities of Openbox are really huge.

4. Conclusion

First of all sorry, if my story in this post in not fully complete. But I prefer to split is in peaces because it will be much too long (for me to write and for you to read).

In general I thanks all OpenBSD developers for their great job. Here I will mainly thanks the persons who are maintaining the "ports", the different applications we can have, pre-compiled, on OpenBSD.

As you saw most of the applications listed here are present in the OpenBSD's catalog.

Thanks to Openbox developers, this lite window manager runs perfectly on OpenBSD. I've show that we can add easily extra applications to make it more easy for lambda users.

What amaze me also is the stability of the OpenBSD concepts. Release after release they are not revolutionising their OS, but they are just evolving it. This is a huge difference for me, because, personally, I spent less time to understand how things are working. I'm using it, on my desktops and laptops since +5 years now, and I've never been disappointed, or lost, after a release.

All in all, I hope that this text could be a trigger for some persons to give OpenBSD a try on Desktops and laptops.



8, 3
displayed: 2321
Comments:

1. From flaketill on Tue Mar 14 06:06:48 2017

I love GNU/Linux and BSD, I've both with openbox, tint2, xmobar and conky




How much does 6 plus 2 ?