Open Source

SolutionBase: Creating the perfect user terminal with BlackBox

Creating and locking down custom desktops can be difficult. Using the BlackBox window manager in Linux, however, you can create simple, effective terminals for end users with just a little bit of tweaking. Jack Wallen shows you how.

This article is also available as a TechRepublic download.

Let's say you have a group of machines that need to be used by various users in a department, shop floor, classroom, or coffee shop offering internet access but each of those machines needs to only serve certain functions. For various reasons, you don't want to have to create different machines to serve different functions. You simply want to lock each machine down so that machine can only function in a particular manner. What's the best way to get it done? If you're using Linux, one way to do so is by using the BlackBox window manager. Here's how.

Enter Linux and BlackBox

Old school Linux users will remember the BlackBox window manager from the Linux desktop heyday before the bi-partisan system of KDE and GNOME arrived. This particular window manager can be configured to make your users think the terminal they are working on can only do certain things.

But before we dip our fingers into a little Orwellian pudding, let's first get BlackBox installed.

I will define the installation process with the apt-get installer due to its ease, popularity, and the fact that it is text based. Using apt-get you will want to first ensure that you have the standard apt repositories in your /etc/apt/sources.list file. I am going to assume an Ubuntu installation which will want you to add the following (as the root user) to your sources.list file:

deb dapper-cafuego all

deb-src dapper-cafuego all

With these repositories in place the first command you will run is to update your installed package base with the command:

apt-get update

Now you are going to install BlackBox with the command:

apt-get install blackbox

Now, just for insurance, let's update your entire distribution with:

apt-get upgrade


apt-get dist-upgrade

Now install bbkeys (the BlackBox keybindings tool) with:

apt-get install bbkeys

Finally, install the bbtools package which contains a number of useful tools (such as bbdate, bbsload) with:

apt-get install bbtools

and you're finished with the installation.

Running BlackBox

You probably already have your Linux box working with a graphical environment - either KDE or GNOME. That being the case, you will probably have either GDM or KDM (the graphical login tools) running. In some instances these log in managers will not give you an option for your newly installed BlackBox Window Manger. If that's the case your Linux box will need to halt to run level 3 at boot. To do this you will need to open up the /etc/inittab file and change:




When you reboot your machine, the machine will now boot into safe text mode. But wait, how do you get your new graphical environment to run? Open up your favorite text editor (mine happens to be Pine) and write the following:

exec blackbox

Save this file as ~/.xinitrc and exit your editor. Now to start up the graphical environment you only need run the command startx and viola! BlackBox will very quickly be up and running. NOTE: When I say quickly I mean QUICKLY! BlackBox demands a very low overhead, so the only drag on your machines resources that you will notice will come from the programs running.

BlackBox basics

When BlackBox is first running you will only notice two items: the Slit and the Toolbar. The slit is the equivalent of the dock in other window managers. Not all window managers or desktop environments have a similar feature, so you may or may not have seen anything similar before. The slit is a rectangular bar stuck to one of the screen margins. Its purpose is to swallow small applications designed especially for this purpose and to keep them in a common, block-like, place, in a handy location available easily. The slit by itself does nothing, it is just a rectangular container. People use the slit to load applications that display info about the system or offer a quick way to access some functionality. Examples: keep an eye on CPU or memory load; quick access to audio mixer volume; check new emails; a fancy clock.

You might think the Slit to not be necessary. However, this little tool will come in handy for having a running clock, date, and pager (if you so desired.) Should you want to run the Slit with, say, the date and the time running you would run the commands:

bbdate -w


bbtime -w

The -w option tells the program to run only in the Slit. Pretty handy. Of course should you want to have the date/time in the Slit at startup (in other words, without you're having to start them manually each time a machine is restarted) you would want to configure these application to start in your ~/.xinitrc file as such:

bbdate -w

bbtime -w

exec blackbox

The other tool you will see, upon startup, is the Toolbar. The toolbar was created in order to offer a minimal amount of absolutely essential information to the Blackbox user. This includes the following:

  • The name of the current workspace being viewed.
  • The name of the currently focused window.
  • A configurable clock (actually, a string using date flags which can become a flexible representation of the current date and time).
  • Arrow buttons so you can change workspace and window focus with the pointer (mouse).

Because of the minimal nature of the toolbar (and the ability of the Slit to show date/time) I suggest getting rid of the tool bar. This will rid you of user-confusion when the user accidentally hits the arrow button sending them to a different desktop that doesn't have their Browser (or whatever application they happen to be using) running. Next thing you know you have a terminal with more than one instance of FireFox running.

So, if you want to get rid of the tool bar, starting with version 0.70, it can be disabled completely. See the config submenu in the Blackbox menu.

The BlackBox menu

This is where BlackBox shines as a terminal window manager. With the BlackBox menu you can configure this machine to effectively only open the programs you want to open. And without a menu entry, the only way a user would be able to run a program not in the menu would be to open an un-approved application.

In the BlackBox menu each line is a separate menu definition and each definition cannot span more than one line. Empty lines (ie. containing only whitespace) and lines that start with # (comments) are ignored. Everything from a comment mark to the end of the line is ignored. This makes it possible to have valid content at the beginning of a line and a comment later on the same line.

Each definition looks like one of the following:

[command] (label) {data}

[command] (label)


The [command] entry is always mandatory. The {data} entry can be absent and sometimes both {data} and (label) can be absent. But you can never have a [command] and {data} without a (label) in between. At the very least a valid BlackBox menu entry must contain the following data:

[begin] (Some label) least one entry, no matter of what type...


One of the coolest things about the BlackBox menu is that it does have a semblance of error handling. Should you totally corrupt a menu, the system will render a menu with a bare bones entry as such:

[begin] (Blackbox)

[exec] (xterm) {xterm}

[restart] (Restart)

[exit] (Exit)


As you can see this menu will give you three entries: an xterm (terminal window with which you can re-edit your menu), a restart entry (with which you can restart BlackBox), and an exit entry (with which you can exit BlackBox.)

Now, let's create a menu for a BlackBox terminal (called Serenity) that will allow the user to do three things: Browse a network with FireFox, write a text document with OpenOffice, and write a spreadsheet with OpenOffice. That sparse menu will look like:

[begin] (Serenity)

[exec](firefox){Browse The Web}

[exec](oowriter){Write A Document}

[exec](oocalc){Create A Spreadsheet}


Simple as that. This menu will be a text file called menu (with no extension) housed in the ~/.blackbox directory. You will notice that this menu does not contain either a restart or an exit entry. This is done so that our users can not drop into command-line mode unless they know the Ctrl-Alt-Backspace key sequence. This, in conjunction with the menu NOT containing an entry for a terminal program, will keep the users from running unwanted applications.

Of course you might want to have a more detailed menu for your terminals. Here are some tips and tricks for the BlackBox menu.


The [nop] command is used to create an inactive menu item, which can be clicked on but doesn't actually execute anything. Say you want to delineate menu entries with a dotted line. To do this add:

[nop] (————————)

to your menu where you want the dotted line to be placed.


The [submenu] command is used to open a new submenu. New submenus may be overlapped to any depth. Submenus MUST be nested properly. It MUST have a label, which will be rendered as the heading title for the submenu. It SHOULD NOT have data. So let's take our above basic menu and give it a submenu for the office applications.


[exec](firefox){Browse The Web}


[exec](oowriter){Write A Document}

[exec](oocalc){Create A Spreadsheet}



As you can see there are two [end] tags. The first [end] tag is for the submenu and the second for the entire menu.

It is this menu structure that will allow you to create a terminal specific menu that will only let users open those programs you have created menu entries for. You will notice that in the above menu there is no exit or xterm entry . The lack of an exit and xterm entries will keep the users from being able to have access to the command line – further controlling their ability to open unwanted applications.

Changing the wallpaper

You're probably asking yourself what does this have to do with IT? Well, if you are working with visible terminals that will on a showroom floor, kiosk, or of any other visible nature, you will not want them to have the standard BlackBox background (a sold color most likely). And you're probably used to either KDEs or GNOMEs right-click change background nature. Not so in BlackBlox. As I've said before, BlackBox is old school Linux and old school Linux most often requires a hack or two of a resource file. And that's exactly what you are going to do. But first you need to understand the concept of the root window.

On the X desktop there is an invisible window present at all times. This invisible window is called the root window. This window is exactly the same size as the screen and stays below all other windows at all times.

The root window can be used for several main purposes:

  • Displaying a wallpaper or a color pattern
  • Catching mouse clicks in order to perform certain actions or pop-up menus
  • Displaying icons, application shortcuts, or other widgets

So what Blackbox does (with the help of a the root window and a command or two) is load an image to serve as the background and/or catch and act upon mouse clicks.

With that understood, let's highlight the configuration of the BlackBox background. Your BlackBox installation will be using a default style. The styles are located in /usr/share/blackbox/styles. Within the styles directory you'll see files that are the resource files for each theme. Within those files you'll see a line that looks like:

rootCommand: bsetbg /home/user/.blackbox/backgrounds/simple.jpg


bsetroot -gradient gradientdiagonal -from rgb:9a/97/94 -to rgb:7a/77/74

  • In the first listing the rootCommand entry tells BlackBox that what follows deals with the root window. After that is bsetbg which is the set background command. Following the bsetbg command is the explicit path to the background picture.

    The second listing takes a different approach with the bgsetroot command (which directly communicates to the root window) and sets an rgb color gradient for a background.

    All you need to do to set your company's logo in the background of your BlackBox terminal is to use the bsetbg entry in the theme of choice for your BlackBox installation.


    And now your BlackBox terminal is ready to rock your company. This set up will make it so simple for you to roll out dumb terminals that will only allow your users to run specific applications and keep them from running those applications that suck away precious work time or compromise security.

  • About Jack Wallen

    Jack Wallen is an award-winning writer for TechRepublic and He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website

    Editor's Picks

    Free Newsletters, In your Inbox