Put Linux into Old PC - (2) Desktop Environment

2016-05-18 by terryoy, in guides

Part 2. Setup a minimal desktop environment

2.1 Xorg and Openbox

To use a desktop environment, Xorg is the package you won't miss(for more information you can also check the x.org and freedesktop.org web-sites. I choose Openbox as the window manager, which is one of the most lightweight window manager. It is the best showcase of minimalism, yet the functions shall be simple enough for customization. The window manager is not a desktop environment, it is just simply a manager to windows, their styles and behaviors. A complete desktop environment is not necessary, or maybe it's the chance that I could design my own.

$ sudo apt-get install xorg
# now you can enter the GUI environment by command "startx", but you still need a window manager to do further things
$ sudo apt-get install openbox obconf openbox-themes
# the above packages and their dependencies will allow you to build and configure an Openbox system, along with choices of themes.

What's interesting about “startx” is that, if you try it after you install xorg and before any Window Manager, you'll get a graphical shell environment with mouse available. The font is definitly different from what you had in the normal console. It is I think the essential GUI environment possible. And if you press Ctrl+D to exit the session, you get back to your original console environment, so the xorg-session is exited.

After installing the openbox package, it's not yet completed. You also need to add the a ~/.xinitrc configuration so that it calls the openbox when you execute “startx”.

$ echo "exec openbox-session" > ~/.xinitrc
$ startx

Now you can see GUI environment by Openbox. Right click on the desktop and you get a start menu, you can start a terminal emulator or configure the openbox using Obconf.

If you see an error says cannot get access to ~/.Xauthority, it's possibly you ran it in root user. It doesn't need to be root user, and you should chown the file to yourself.

Before going to the next step, let's look for a better console terminal than the system default one(xterm), otherwise it's inconvenient to work on multiple sessions and copy&paste text. The lxterminal is lightweight and good enough.

$ sudo apt-get install lxterminal

Then you can try it out with the right-click menu and select “Terminal emulator”. You can check the key-bindings in LXterminal's Preferences menu.

Next we try to do more about the customization.

2.2 Openbox Configuration (menu.xml and rc.xml)

Openbox has two main configuration files:

  • rc.xml, which sets keybindings, desktop names and window behavior
  • menu.xml, which contains the instructions for the right-click menu.

The configuration files can be found in /etc/xdg/openbox/, while you can have your user-specific version in ~/.config/openbox/.

Reference for OpenBox: http://openbox.org/wiki/Help:Configuration

2.2.1 Desktop behaviors

First we look into some settings in rc.xml. Most of the configuration items you can found them in the Obconf program, which is right in the desktop's right-click menu.

The configurations are mainly in below categories:

  • Resistance, distances for handling window moving behavior, such as overlap and moving towards different desktops.
  • Focus, behaviors for switching window focus with mouse.
  • Placement, decides the position when a new window is displayed
  • Theme, this is where you can customize the visual design of the environment. (I will cover the Theme customization in the following section.)
  • Desktops, desktop behaviors
  • Resize, resizing and moving windows
  • Margins, the desktop margin settings(the boundaries where windows will not resize to…)
  • Applications, customize settings per application. You can also configure this with an GUI app ObApp (will cover later)
  • Keyboard, keyboard shortcuts and behaviours
  • Mouse, mouse shortcuts and behaviours
  • Menu, right-click(system) menu behaviours.
  • Dock, dock-apps settings, it's kind of apps that will have docking behaviours

The other configuration files is menu.xml. It defines the system menu content and is referred by the rc.xml. Since the content are quite obvious, I don't need to tell more about it. Check out the wiki page for customizing menus, notice it can also has “Pipe menus” where the menu content is genereted from the pipe of the command line results, which means you can programs to hack. ;-)

There are also two files under /etc/xdg/openbox. One is autostart, you can include some initializing scripts here when an Openbox X Session is started; the other file is environment, where you can set system wide variables for the Openbox session. Both of them can be user specific by creating files with the same name under ~/.config/openbox/.

2.2.2 Openbox Themes

You can create your own themes for better looking of the desktop environment. The file structure is like below:

ThemesDirectory  (such as /usr/share/themes, ~/.local/share/themes or ~/.themes)
 |
 +-> ThemeName  (This is the name of the theme, such as Clearlooks)
      |
      +-> openbox-3  (This the type of the theme - it's for Openbox 3!)
           |
           |-> themerc  (This is the main theme file, documented in this page)
           |
           |-> max.xbm  (These are optional xbm masks for the titlebar buttons)
           |-> close.xbm
           ...
           +-> shade.xbm

I have created a theme called “LinuxInOldPC” under “~/.themes/”, with the openbox-3 folder and the default themerc file inside. The content template can be copied from the wiki page at the end of this section.

Wiki of Openbox Themes: http://openbox.org/wiki/Help:Themes

2.2.3 Key-bindings

Here is a small trick where I would love to have, to conveniently dock the active window to part of the screen.

Reference for Windows docking: https://gist.github.com/terryoy/5486156

Another OpenBox Guide: urukrama.wordpress.com/openbox-guide/](urukrama.wordpress.com/openbox-guide/)

2.3 A simple web browser that do the trick

After searching the apt-cache library for web browser, I discover there is a simple browser called surf, which uses WebKit/Gtk to render. I think this tool is well enough for browsing modern web sites, and also friendly to command line. So I pick it for the initial choice of a browser for me to search information online on this computer.

$ sudo apt-get install surf

Surf has no tab support, no menu no any distractions. If you want to navigate to urls, hit Ctrl-g to enter a new URL.

Reference for “surf”: http://surf.suckless.org/

Next I also give a try to Chromium, the open source version of Chrome. It seems this more sophisticated version of webkit browser also works fine under linux. The performance on loading static web site is quick. So I decided to use Chromium as my default currently.

But now we have a problem here, what if I want to change the default browser in OpenBox? Debian provides a program call update-alternatives so that you could set default program for specific purpose.

# list current default program settings
$ update-alternatives --get-selections

# update a default program
$ sudo update-alternatives --config x-www-browser

It will prompt you an option list of possible programs, so that you can easily decide which program to use.


Tags: linuxstudy