More desktops Build a desktop................
Never happy with the default state of affairs, Mark Chisholm pieces together the software required to make a usable desktop environment.
Never happy with the default setup, Mark Chisholm shows you how to piece together a usable desktop environment by hand.
Were you to ask people what their favourite part about Linux is, they would probably say that they enjoy its stability and performance. They might also say that they like its security. It excels in all three areas due to the heavy influence of the UNIX operating system. Its modular nature means that even if one part of the Linux system fails, all the other packages and services running on the system will keep going.
The thing we enjoy most about its modular nature is that it can be pulled apart and put back together. While there are Linux distributions out there that expose that modular aspect to the user such as Gentoo (or its more user-friendly spin-off called Funtoo), you don’t need to go through a Gentoo install to get the most out of its customisability.
Environmentally unfriendly
This has been a controversial topic in the past few months within the Linux community, following a decision made by Canonical to drop its Unity desktop environment support for Ubuntu and return to its Gnome-based roots. A desktop environment is a collection of software that enables the user to interact with the system in a user-friendly way as opposed to a simple TTY console where otherwise you’d be expected to use terminal commands the whole time.
Because desktop environments are a collection of software rather than a single monolithic package, this offers a lot of modularity and makes it easy to put together your own. Desktop environments are one of the few aspects about Linux that retains modularity, but doesn’t have a whole lot of complexity added to it.
Making a custom desktop environment is an easy and safe way to delve into the world of customising your Linux system. We’re not customising the Linux kernel or Systemd, so there are no kernel emergencies if something goes wrong. You most likely already have a desktop environment installed, so if something doesn’t go according to plan the first time then you can always log into your existing desktop environment and try again. And of course, nothing beats the feeling of knowing that you have a desktop environment customised to your needs.
You will (hopefully) be pleased to know we’re aiming to keep this independent from any particular distribution. The techniques outlined here will work if you’re on Ubuntu, Fedora or Arch-based distros. So there’s no need to jump to a new distribution. We do, however, make the assumption that your system is up to date, and you know how to install software through your package manager.
Software choice
Probably the hardest part of this tutorial is picking and choosing the software you want to use in your new desktop environment. What follows is just a small roundup of software – it barely scratches the surface of available options out there. Our program choices reflect what we think are essential
to having a desktop environment that you want to use for everyday usage.
Window managers
These control the appearance of application windows and also enable you to drag and move windows – keeping them maximised, minimised or closed. It’s not uncommon for users to choose to just use a window manager, but for a usable desktop environment we need more than just a simple window manager.
Openbox
It’s no surprise that openbox gets a mention here, because it’s been a favourite of the Linux community since its initial release in September 2002. It’s written in C and was released under the GPLv2 licence. It’s also what’s called a stacking window manager – to understand how it works, imagine your windows as pieces of paper stacked on a desk. If you choose this as your window manager, then be sure to install the obconf package as well because it offers a lot of openbox customisation options.
i3
This is a tiling manager that’s unique from stacking window managers, because they tile the windows so that they don’t overlap. If you want to try a window manager with lots of keyboard shortcuts to speed up your workflow (or speed up looking at cat videos on YouTube) then i3 is a great alternative to Openbox.
Awesome
This window manager is highly configurable. It’s written in C with a well-documented Lua scripting API for extensibility. It’s designed with power users in mind for the people who want very fine control over their window manager. Awesome was also the first window manager to use the XCB (X-Protocol C-language binding) library instead of using the older Xlib library. This means it has direct access to the X protocol and improved multithreading.
File Managers
While it’s entirely possible to manage your files through a terminal, having a GUI for it is a luxury that we can afford because they don’t require a lot of resources or take up a lot of space on a drive. Of course, since this tutorial is all about making your own desktop environment, you could omit file managers entirely.
PCMan File Manager
This is a file manager created using the GTK2+ toolkit, although there’s also a Qt variant available called PcManQt. It may appear basic, but this is a file manager that supports SFTP, WebDav and even Samba, along with volume management and the auto mounting of drives.
Thunar
Unlike the PCMan file manager this doesn’t have a Qt version; instead, it’s entirely GTK based. It’s similar in functionality to PCManFMthunar and does have a lot of GTK addons available to use. It even has dropbox support.
Composite managers
These are extensions for the X window system. The X window system is not a window manager in its own right, but rather a display server responsible for outputting a screen. It’s not entirely necessary but it does give a lot of eye candy to an otherwise bland desktop environment.
Compton
This standalone window manager adds effects such as window transparency and shadows. Easy to use and light on system resources and very customisable with the option to use custom config files. Just be sure to back up the config file if you do decide to make changes to it.
Compiz
This compositing window manager makes use of 3D graphics hardware. We realise this option won’t be for everyone because its requirements are a little higher than some would
expect, it does have a lot of compositing effects for the animations of minimising and maximising windows, as well as offering a cube workspace. Most dedicated 3D graphics hardware after 2006 will work, but you may experience lag if you try it in a virtual machine or with integrated graphics processing units. There are some pre-made themes on its website, over at www.compiz-themes.org . These may appeal to some users if they don’t want to manually edit the compton.conf file.
Docks and Panels
Panels are the part of a desktop environment that can show open windows and display the time with the log out and restart functions. You can use an existing panel if you already have a desktop environment installed. You can also configure panels in Openbox if you have the obconf and obmenu packages installed.
Docks, or at least the dock we will be recommending, can imitate the look of Apple’s OS X. We expect some of you may be cringing at the thought of making a desktop environment to eventually look like OS X, but rest assured they can also be customised to closer emulate the dock in canonical’s Unity desktop environment, or something different entirely. So if you liked what you saw in LXF231, which featured Ubuntu with the new Gnome desktop environment, you’re in the right place if you want to make something a little closer to Unity.
Docky
This dock is similar to Cairo-Dock. The drawback to using docky is that it has a dependency on the Mono package, which while technically does add extra overhead we did have it running on an Intel Atom with integrated graphics without any issues of lag or slow performance. Docky also has docklets that contain extras such as weather applets and even battery monitors. If you choose Cairo-Dock and are in a virtual machine, it will ask if you want to use OpenGL. The safe option in a virtual machine is to leave it disabled but on real hardware, feel free to enable it.
Feh
Feh is a tool aimed mostly at console users (some people omit desktop environments entirely, but the jury is still out on whether or not its admirable dedication to the terminal or inconvenient). We mention it because lightweight window managers aren’t able to display a desktop wallpaper. We’ll need feh to set the image on the root window – by which we mean the background of the window, not root as in the super user.
All together now
The desktop environment we’ll be making will consist of Docky for the dock, Thunar as the file manager, openbox as the window manager and compton to composite it all. Feh is there just for the desktop wallpaper. You can replace, omit or even add some of the packages as you see fit, but now we need to create a shell script that executes all the pieces of software we want. Simply put, a shell script is a file with a list of commands that execute those commands in the terminal. Shell scripts are also useful if you find yourself doing repetitive monotonous tasks in the terminal and wish to automate the process. This shell script is about as basic as shell scripts get, in that it literally is just things being executed in order with no if / else conditions.
To create the script enter the following command: sudo nano -w /usr/local/bin/customdesktop
This is the script we’ll be using: #!/bin/sh docky & thunar & feh --bg-fill /home/user/desktopwallpaper.jpg #Remember to change the path appropriately compton -c --shadow-exclude ‘n:e:Docky’ & openbox
Once done, press Ctrl+O to save, then Ctrl+X to exit the nano text editor.
Background operators
The & in the script tells the system that those programs are to run in the background and not to be closed as the next one opens. Onto the Feh part of the script, and you’ll notice an added a comment in there. Comments in shell scripts are declared with the # symbol and are completely ignored by the shell, but that doesn’t mean you get to ignore the advice. The path to the picture you want to use as your root windows desktop wallpaper should be changed. For example, if you have a picture you want to use for the desktop background, save it to a folder called Pictures in the home directory; the path would be /home/mark/Pictures/<name_of_File>.
Remember that file extensions are important as well. The example <name_of_File.jpg> is not the same thing as <name_of_File.png>.
This applies to capitalisation as well. Docky is not the same thing as docky and the shell script won’t launch Docky because it expects to find it lowercase and not capitalised.
The compton -c --shadow-exclude line is there because we want to stop compton drawing shadows around docky. Docky has its own compositing effects that work with compton providing there are not two applications both trying to draw shadows at the same time.
This file is also the only file you actually need to change if you later decide that a certain package isn’t what you want. All you need to do is install the new package and their dependencies through the package manager and then edit this script to reflect the new changes you made. If, for instance, you wanted to change thunar for PCManFM, then all you’d need to do is replace thunar with pcmanfm .
Not quite done yet. All we’ve done is create a text file that isn’t ready to be executed. If you were to try running the shell script after that, you’ll get a permission denied error because the file doesn’t have executable permissions. To change the permissions of the file we need to enter this command: sudo chmod +x customdesktop
The next thing we need to do is create a .desktop entry. This is the part that tells the login manager that our newly created script launches a desktop environment. If you were to log out right now after installing openbox, you’d see that your login manager now has an option to login with openbox or most other window managers for that matter. This is because when they’re installed, a .desktop file is placed in /usr/share/xsessions. To create our desktop entry we need
to go over to the /usr/share/xsessions directory, so use the following command: sudo nano -w /usr/share/xsessions/customdesktop.desktop And this is what gets entered into the
Create a desktop entry
nano [Desktop Entry] Name=CustomDesktop Comment=Custom desktop Exec=/usr/local/bin/customdesktop TryExec=/usr/local/bin/customdesktop Type=XSession editor: Once done, press Ctrl+O to save, then Ctrl+X to exit the nano text editor. A desktop entry is a standardised format agreed upon by the KDE and GNOME community for bringing applications into a desktop environment. They are more like a configuration file as opposed to a shell script, which is a series of commands. They describe to the system how an application is launched – and the most obvious example of this is when we’re at the login screen.
Once that’s done, you’ll now be able to log out and log back in after choosing your desktop from the list of available desktop environments in the login manager. It can still look a bit barebones though, so let’s start configuring openbox. If you have the obconf package installed you should now be able to right-click anywhere on your new desktop and see an option for obconf.
Click that and you should now be able to customise the appearance and behaviour of openbox, our window manager. There are some themes bundled in by default but you can get more on the openbox website here: http://openbox.org/ download-themes.php.
Onto docky now. A thing to remember about docky is that it needs a little encouraging remembering which applications you want to launch. When you first log in it will enable you to open common applications – providing you have them installed – such as Firefox the web browser, thunar the file manager and a rubbish bin.
One possible workaround is to open a terminal, enter the name of the application and then press Enter. Once the application is launched docky will have a launcher available for it to be used. Just right-click the launcher and pin it to the dock as usual. Docky can be customised a little further though… just keep reading!
If you click the icon that looks like a blue anchor, it brings up the docky Settings panel. This enables you to add and delete new docks and change the appearance of the dock. Accessing the panel mode makes it possible to rid of that OS X-like appearance if you want.
The compton config gets put into /etc/xdg/compton. conf on some distros, such as Arch Linux. If it’s not there then you may have to make use of the mlocate package that should help in locating the file. Just open a terminal of your choice and enter the following command: sudo updatedb && locate compton
For using the config file you can tell compton to do so with this command: compton --config <path_of_config_file>
There you have it! A desktop environment you can customise to your every need and want. Furthermore, it’s easy to customise it even further if you wish and who knows – your custom desktop environment could find its way into a mainstream Linux distribution if other people enjoy it as much as you do!