Pimp my *buntu

People are different and if there is one thing, that you can do on Linux, it’s being different, we have lots of different distros, different desktops and applications. That is already pretty cool but you can also fairly easy spice up your existing desktop without doing such fundamental changes. And through combining different elements you can turn your desktop into something individual that nobody else has and that often requires just a few clicks. This is written for Ubuntu with Unity in Mind but it work just the same for Mint with Cinnamon or MATE, for other desktops such as KDE or Openbox you can find similar functions in other tools.

Get a nice wallpaper

Wallpapers are like the face of your desktop, while at work you won’t see them often but they are usually the first thing you see after logging in. So change it into something you like.

Most distros already come with a wallpaper package pre-installed, Ubuntu has besides the official wallpaper about 10 community wallpapers that you can choose from via System Settings -> Appearance. If you search your package manager for the keyword “wallpaper” you will find even more packages that you can install, they are from previous versions or from other *buntus. For more recent packages you can search packages.ubuntu.com, installing them on your system shouldn’t be a big deal, they are just images (jpg, png).

If you want something more individual, you can use your own images or use the Google Image Search to find pictures of your favorite band, singer, actor, model, movie, car, animal or whatever you like. I like music, so I have a lot of wallpapers made from live footage or promotional images. Use Gimp or Pinta to crop them to fit your desktop best, that’s really easy and makes it look a bit nicer.

You can also install a wallpaper changer like Variety or Wallch, they allow you to do a lot of cool things like turning your desktop into a slightshow or a clock, use various online sources or just manage your own wallpaper collection in an easy way. You can install Variety via PPA
sudo add-apt-repository ppa:peterlevi/ppa
sudo apt-get update
sudo apt-get install variety
Wallch is available from the official repository, so it’s just
sudo apt-get install wallch

Dorian Faenza

My desktop (Unity) with Dorian Theme 3.10 and Faenza (darkest) Icons

Get a cool theme

You might know themes from applications such as Firefox, that allow you to change the appearance of the user interface by installing a theme or persona. On a Linux desktop you can do the same with all applications (unless they are really exotic).

The basic decision you have to make is whether you want a light (dark text and controls on a light background) or a dark themes (light text and controls on a dark background). Most distros come with a light or mainly light theme as default. Personally, I prefer a theme that is dark, I find it easier for the eyes, in particular if you spend long hours in front of the screen. However, it might not be to everyone’s cup of tea, but you should give it a try. Also keep in mind that white (or other really bright colors) on black can be just as bad as black on white, so unless you need it, you should avoid too high contrast.

Again your standard installation already has a couple of themes, you can play with them first to get at least an idea which way you want to go. You can change to them via System Settings -> Appearance. A more comfortable way is Unity Tweak Tool or GNOME Tweak Tool, both are available from your package manager.

Again finding themes through Google or another search engine isn’t much of a deal, I have listed a few sources at the end of this article. However, you have to keep in mind that a theme is not necessarily compatible with the version of you distro, on Ubuntu this is due to the different GTK versions. Installing a theme is fairly simple, you just have to unpack it and place it in either /usr/share/themes (global) or ~/.themes (local), but many themes that are compatible with your system will also be available as a package that you can install via your package manager.

If you choose to download a them manually (e.g. as a tar ball) you need to know your GTK version, this can be done by running
dpkg -l libgtk2.0-0 libgtk-3-0
If you find a theme that requires GTK 3.14 and you have only GTK 3.10 (Ubuntu 14.04 LTS), it won’t work.

Ambience Blackout zonColor

Same desktop with Ambience Blackout (Graphite Pro) Theme and zonColor (grey) icons

Get some new icons

With your new theme you might notice that your icons look out of place, they are hard to identify, for example when you have a dark Unity panel and dark panel icons (or the other way around), or they simply do not fit the style.

Icons are in many or most regards just like themes. You will find many, that differ in shape and colors, you get monochrome ones, flat ones, colorful ones, some will offer new application icons, others use the default ones. So I guess there is a bit of something for everybody. The problem with very special icons (like monochrome ones) is, that you do not always have a matching icon for all applications.

Icons are stored in /usr/share/icons (globally) and ~/.icons (locally) but again, there is often no need to do it manually, cause you get the as installable packages or via PPA. To change them you can also use Unity Tweak Tool or GNOME Tweak Tool.

On an aside, if your system is a bit week on disk space, don’t try too many icon packs at the same time. A single icon is often just a few kB but a full package can contain hundreds or thousands of files, resulting in many, many MB (in extreme examples up to 1+ GB on disk).

Hackstation Ravefinity x

Current version using Hackstation theme with Ravefinity x (full dark red) icons

Useful sources

  • NoobsLab: if there is one site that has everything related to themes and icons for the *buntus it’s Umair Riaz’ NoobsLab. It has screenshots, detailed install instructions and lots of useful tips. Noobslab even runs it’s own PPAs to conveniently install many packages. With an Ubuntu based distro, this is certainly the site to go to.
  • GNOME-Look: most likely one of the standard sties for everything related to theming for GTK based desktops, you find similar sites for all kinds of desktops (KDE, the various box desktops).

Closing words

I know, this post is a bit vague, but really, I don’t want to tell you what to do. YOU need to find YOUR style, it’s your desktop and you have to look at it every day. I just want to show you that you can change these things, how you can change them and where you find some useful stuff. I want to encourage you to try it. The rest isn’t my job. Download, install, experiment. It’s really simple.

Installing Pale Moon for Linux Manually

In a previous post I have shown how to install Pale Moon using pminstaller. Some people might not like the idea of having a script change something on their system, they can easily install Pale Moon manually. And by install I mean having proper icons, a launcher and menu entries, just like any other application. You can also just download the tar ball, extract it and run the binary, however, I would not consider that installed but it has the benefit that you do not need to have root access.

Most of the following will be done using the terminal and most of the commands will run as root, so we will be using sudo a lot. For the sake of easy you can also use sudo -i to open a root session. This was written for an Ubuntu installation (using Unity) but most of the steps are also needed for other Linux systems, in worst case you get commands that aren’t working.

Downloading Pale Moon

You can download Pale Moon in the Download section of the linux.palemoon.org website. I suggest to use the browser you are currently using, you could use wget but therefore you need the download link for the most recent version, that one is available on the site mentioned, so it makes sense to download it directly.

Before you start downloading you should make sure to grab the correct version for your systems architecture. You can check that using commands such as arch or uname -m (or uname -a if you want some more details).

You might know 32 bit and 64 bit, that is basically it but you might read things like x86, x64, i686, i383, amd64 and the likes when it comes to systems and applications, so what is what? For what you need, it is fairly simple
32 bit=x86=i?86 (with ? being 3, 4, 5 or 6)
64 bit=x86_64=x64=amd64
Yes, that is confusing, if you are not used to it.

uname and arch will return i?86 for a 32 bit system or x86_64 for a 64 bit system. So, on a 32 bit system, you need to use the download link labeled x86 which gives you a file labeled i686. On a 64 bit system, you have to use the download link labeled x64 that gives you a file labeled x86_64.

Installing Pale Moon

Like pminstaller, we are going to install Pale Moon to /opt, so first you should make sure that the /opt directory exists
sudo mkdir -p /opt
then extract the tarball to into that directory
sudo tar -xvf "<path to Pale Moon archive>" -C /opt
Next you create a symlink in /usr/bin
sudo ln -vs /opt/palemoon/palemoon /usr/bin/palemoon
so it is in the path. In a way that is it, Pale Moon is installed now, so when you type palemoon in the terminal, Pale Moon will open. This is the point where many blogs end their “tutorials”, but you might notice that some things might be missing.

Creating a launcher

That can be done fairly easy, because the launcher is available on GitHub, so grab it from there
wget https://raw.githubusercontent.com/MoonchildProductions/PM4Linux-installer/master/files/palemoon.desktop
and copy it to /usr/share/applications/
sudo cp palemoon.desktop /usr/share/applications/
You should now have a launcher for example in Unity’s Dash or in your start menu that shows up when you look for Pale Moon.

Creating the icons

Visually, there is still something missing, that is pretty obviously an icon. That can be done by either copying the icons to hicolor theme or by simply symlinking them there
sudo ln -vs /opt/palemoon/browser/chrome/icons/default/default16.png /usr/share/icons/hicolor/16x16/apps/palemoon.png
sudo ln -vs /opt/palemoon/browser/chrome/icons/default/default32.png /usr/share/icons/hicolor/32x32/apps/palemoon.png
sudo ln -vs /opt/palemoon/browser/chrome/icons/default/default48.png /usr/share/icons/hicolor/48x48/apps/palemoon.png
sudo ln -vs /opt/palemoon/browser/icons/mozicon128.png /usr/share/icons/hicolor/128x128/apps/palemoon.png
Than update the icon cache
sudo gtk-update-icon-cache -f /usr/share/icons/hicolor
Now you should see that your launcher has an icon.

Registering with the alternatives system (optional)

You don’t have to do that but to make Pale Moon standard on your (Debian based) system, you have to register it with the alternatives system and make it the default. The entries of interest are x-www-browser and gnome-www-browser. First I would check these two entries (usually, they have the same values set, so I will show it for just one in detail)
update-alternatives --display x-www-browser
this will return values like /usr/bin/firefox - priority 40 and link currently points to /usr/bin/firefox tells you what is the default for x-www-browser. You can try that by typing x-www-browser into your terminal, if, like in the example, your default was Firefox, it will open Firefox.

To change that, you have to register Pale Moon and give it a higher priority (the example gives it a priority of 200)
sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/palemoon 200
Now it should tell you, that the default is Pale Moon and typing x-www-browser should open Pale Moon instead of Firefox. The drawback if that, if you install another browser (e.g. just for testing) that gets registered with a higher priority that one will be default. To change it back to Pale Moon, you can select it manually by typing
sudo update-alternatives --set x-www-browser /usr/bin/palemoon

Repeat that for gnome-www-browser.

Integrate hunspell (optional)

hunspell is the spell check that is used by lots of applications and on many different Linux systems, so lots of apps have the same dictionaries. And it is fairly easy to make Pale Moon use the same dictionaries (the dictionaries themselves are just simple lists of words in both cases). You can check which dictionaries are installed by using ls -l /usr/share/hunspell.

First remove your dictionary directory
rm -vrf /opt/palemoon/dictionaries
Then symlink the hunspell directory to your Pale Moon dictionary directory
ln -vs /usr/share/hunspell /opt/palemoon/dictionaries

Updating Pale Moon manually

Updating Pale Moon manually, is even easier. First download the latest version for your architecture in your preferred way.

To start the update, make sure you have Pale Moon closed, it could lead to strange behavior if you run an instance of Pale Moon which changed files. Next remove the old files
sudo rm -rf /opt/palemoon
and unpack the new version to /opt
sudo tar -xvf "<Path to Pale Moon archive>" -C /opt
If you had used hunspell, you have to repeat that step as described above.

Closing words

While this might seem rather complicated it actually is not, it is really just a handful of commands. Basically, this is exactly, what the pminstaller is doing, when going through the article from top to bottom, you get a simplified version of that script. The script was also how I got this set of commands and the article, I just modified them a bit and tried to explain what they are doing.

Installing Pale Moon on Linux – Update

I have already mentioned earlier that Pale Moon for Linux was about to move away from SourceForge for reasons you might already know. Now Pale Moon for Linux is an official Part of the Pale Moon sites having it’s own subdomain linux.palemoon.org. This change also means that there are a few changes for PM4L users. The first one is that the SourcefForge site will no longer receive any updates (so 25.5.0 is the last version hosted on SF). The other thing is that PM4Linux Installer (aka. pminstaller) versions below 0.2.0 will no longer work (so you won’t be able to install or update to the soon[tm] to be released version 25.6.0).

This is reason for me to update my previous article on how to install Pale Moon on Linux. Technically nothing has changed, so it is still the same article, just the links need an update.

Using the installer

pminstaller works like the stub installers many of you might know from Windows. If you not totally new to Linux, installing Pale Moon manually isn’t such a big deal, however, for people who are new to Linux, pminstaller offers a simple way to install, update and remove (who wants that?) Pale Moon. pminstaller is designed to run on virtually any not to ancient version of Linux.

The installer is linked in the Download section. This download does nothing by itself, it’s just a tar.bz2 archive, so once you have downloaded it, you have to unpack it. You can do that easily in your file manager, you will end up with two files pminstaller.sh and the README. pminstaller is a script that you can run on most systems by simply double clicking, you might be asked what you want to do, edit the script or executing it. You have to execute it. That does, however, not work on Ubuntu with the default file manager Nautilus and maybe others (Nautilus always tries to open it in gEdit). In that case, open the terminal (yes, THAT terminal), navigate to that directory using the cd command, if you have saved it to the Downloads folder it’s cd Downloads/pminstaller-0.1.8. Now to run the script enter ./pminstaller.sh (you don’t have to type that, its enough to enter ./p and hit tab).
Bildschirmfoto vom 2015-04-01 15:55:51

Next the script will ask you to enter your password to gain root access. If you do that, you will have a GUI interface like this
Bildschirmfoto vom 2015-04-01 15:58:54
So also pretty nice for those of you who still don’t like the Terminal.

All you have to do now is click Install Pale Moon and the script will offer you to install the latest version of Pale Moon for your architecture. That is it, the script will also create a launcher for Pale Moon, so you can launch it like any other application, it will create the icons, it will also include hunspell if you have it installed (which is likely), so you will have the same set of dictionaries in Pale Moon as in many other applications.

If you do not feel comfortable with the script you can also download Pale Moon manually
http://linux.palemoon.org/download/mainline/
you do not even have to install it, you can simple download the archive extract it and run the palemoon binary, which is useful for testing. A full installation guide (compatible with the installer) can also be found in the Help section
http://linux.palemoon.org/help/installation/

For Arch users Pale Moon is available via AUR
https://aur.archlinux.org/packages/palemoon/
and there is also a PPA available by Marián Kadaňka
https://launchpad.net/~marian.kadanka/+archive/ubuntu/palemoon
with packages for Precise, Trusty and Utopic, I haven’t tested it yet cause I already had the latest version installed when I read about it, so I can’t recommend it yet. But I will try.
(EDIT: PPA wasn’t updated since a couple of versions.) There are also some distributions that already offer Pale Moon officially like Manjaro or Puppy Linux.

Whatever you do, you will end up with a shiny new web browser ready to be optimized and beautified with themes and addons.
Bildschirmfoto vom 2015-04-01 19:31:01
Yours might look different depending on your desktop theme.

KDE and Pale Moon

KDE does not play well with Pale Moon. That is caused by the Oxygen GTK engine. It also does not play well with any other Mozilla-based application but it treats many of them different but not Pale Moon. This problem does not occur with QtCurve. This issue was fixed in the meantime, however, these changes are not yet available for users.

Migrating your Firefox profile

Migrating from Firefox is still fairly easy. You should first start Pale Moon at least once. Next search your profile in Firefox, it is located in a hidden folder in your home directory (.mozilla/firefox) to display hidden folder hit CTRL+H, that a relatively universal shortkey (works in e.g. Nemo, Nautilus and Thunar) if that doesn’t work look in the display options. If you have found the directory containing your profile(s) open you recent profile folder. Now mark everything (CTRL+A) and copy it (CTRL+C).

Now navigate to your Pale Moon profile directory it’s located also in your home directory in another hidden folder and that is .moonchild productions/pale moon, if you just started, there is only one profile in it, open that one, now you can paste (CTRL+V) your Firefox data (overwrite in case of conflict) and start Pale Moon. You might have problems with some extensions that do not work but usually this procedure works pretty well.

If you should have any problems, start by removing themes and extensions. Themes are pretty much likely to not work even though they appear compatible. When you have an extension that doesn’t work, search
http://addons.mozilla.org
for older versions, these are more likely to work. You can also check out Pale Moons own addon site
http://addons.palemoon.org
It is still limited but it is growing.

Adjusting the language settings

Pale Moon is offered in English (en-US) only, if you need another language you can grab the language packs from here
http://www.palemoon.org/langpacks.shtml
Just install them like any other addon. But do not restart yet, open about:config from your Pale Moon address bar and and search for general.useragent.locale and change the string to the name of you language pack (that the part in front of the .xpi part). For example for German you have to download and install de.xpi and change general.useragent.locale to de.
Bildschirmfoto vom 2015-04-01 19:32:47

Something doesn’t work

If something is still odd with Pale Moon, check Help section on the PM4L website
or ask on the Pale Moon for Linux forum
https://forum.palemoon.org/viewforum.php?f=37

Gaming on *buntu: Fallout + Fallout Fixt

Gaming on *buntu: Fallout + Fallout Fixt

This was originally written for No Mutants Allowed.

Difficulty Level: Slightly advanced but still fairly simple.

I have already mentioned that I am a gamer. Gaming on Linux is not yet supported that well, there are a few Linux projects targeting also Linux but the majority is focused on the Windows market. This is not a problem of Linux abilities, a lot of games would run fine, just the Windows market is much larger. If you still want to play, you can for example create a dual-boot system with a Windows system in parallel to your Linux system. However, this is not always needed because there is Wine.

Wine is short for Wine Is Not an Emulator and it allows a program to use Windows libraries on a Linux System. In “intelligent” people call it a compatibility layer, but you can think of it being a translator that translates the output of the Windows components into Linux and vice versa. This works pretty well with a lot of software including a lot of games, old games as well as more recent ones.

In this first part I want to cover a real classic: the original Fallout game. While the original game was released in 1997, it received besides a lot of bugfixes also some massive graphics and gameplay enhancements in the recent years bundled in a project called Fallout Fixt, please check the release thread for download links.

I will be using the GOG version of Fallout, it can no longer be purchased but those who have it, can still download it. For other versions the scenario is pretty similar. So, let’s see how we get that playable on Linux.

Test system:
* Ubuntu 14.04 Trusty Tahr
* Wine 1.7.44
* Fallout 2.0.0.14 aka. the GOG version
* Fixt 0.81.alpha (using a custom setup)

Requirements

In the Ubuntu repositories from Trusty to Wily you find Wine 1.6.2 (that’s the latest stable), you can install it from your package manager (Software Center, Synaptic, etc.). You can also install Wine 1.7 (fairly stable beta versions) from the – more or less – official or officially endorsed Wine PPA using the following commands:
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.7 winetricks
Note: These are the only steps that require root access, do not (really never) install or run applications on Wine as root.

The situation on many other Linux distributions might be similar, sources can be found on WineHQ. In this guide I will be using a basic Wine setup as an example, you can also use Play On Linux, however, it is not needed, but the problems that might arise, should be pretty similar.

Further reading on Wine:
* the official Wine wiki
* the Arch user wiki
* the German Ubuntu user wiki

Creating a Wineprefix

A wineprefix is like a Windows system setup (not like an isolated system), it can be either 32 or 64 bit and can contain different Windows components. It is not required but it is often a good idea to give different programs a different wineprefix. To create a wineprefix you open the terminal and enter for example
env WINEPREFIX="$HOME/fallout" winecfg
On a 64 bit system this will create a 64 bit wineprefix called fallout in your home directory. You can adjust that to your liking but I will keep this throughout this guide as an example. After the creation of the wineprefix the Wine Configuration dialog will open, for now leave it the way it is, but you should remember the env WINEPREFIX="$HOME/fallout" part because it is needed to run an application in that wineprefix.

During installation you will get prompted to install Wine Gecko and Wine Mono, you can cancel that, they are not needed to run Fallout.

Installing Fallout

To install an application on wine you can run
env WINEPREFIX="$HOME/fallout" wine uninstaller
The name is a bit confusing, as it opens the Add/Remove Programs dialog. Click “Install…”.

Selecting the required d3dx9 components in Winetricks

Using the Uninstaller to install Fallout


If you have a download version and saved it to your Downloads folder, just open the download here, if you have it in another place (e.g. outside your home directory), you can navigate to it through drive Z: (that is the same as / on Linux).

For the sake of easy, I chose C:\games\fallout, you should be able to run it using
env WINEPREFIX="$HOME/fallout" wine start /Unix $HOME/fallout/drive_c/games/fallout/falloutw.exe
If you are just looking into playing Fallout, you can stop here.

Installing Fallout Fixt

Fixt is installed in exactly the same way, so open the uninstaller again and chose “Install…”, to make the installer show in the file dialog, change “Files of type” to “Programs (*.exe)”. In the installer simply choose what you like. You could start the game now, however, it would look terrible.

Enabling the Hi-Res Patch

Now you can adjust screen resolution to your liking using
env WINEPREFIX="$HOME/fallout" wine start /Unix "$HOME/fallout/drive_c/games/fallout/Fallout Fixt/f1_res_Config.exe"
also make sure to select DirectX 9 graphics, Sfall will not work with any other mode and make the game crash. I also suggest to enable the Scaling feature, Fallout was designed for screen resolutions in the 640×480/800×600 range, even on 1280×1024 (which is really not much nowadays) things are getting pretty small, as you can see in the screenshots. If you want to use ALT+TAB enable Windowed mode, in Fullscreen mode ALT+TAB wasn’t working at all in my tests.

Fallout Hi-Res Patch Config

Adjusting screen resolution and enabling DirectX 9

Now you can start Fallout Fixt using
env WINEPREFIX="$HOME/fallout" wine start /Unix "$HOME/fallout/drive_c/games/fallout/Fallout Fixt/FALLOUTW.exe"
You should also have a launcher in your start menu to launch Fallout as well as Fallout Fixt.

Enabling Sfall/ddraw.dll

Make sure you have DirectX 9 Graphics enabled in the Hi-Res Patch.

You might notice that Fallout still does not use Sfall, to enable Sfall, start
env WINEPREFIX="$HOME/fallout" winecfg
and open the libraries tab, add ddraw (it’s not in the drop-down, so simple type it and click add, and you are sure you want to do that).

Wine Configuration

Enabling Sfalls ddraw.dll


Instead of changing the Wine Configuration you can also add a DLL overwrite during game launch
env WINEPREFIX="$HOME/fallout" WINEDLLOVERRIDES="ddraw.dll=n" wine start /Unix "$HOME/fallout/drive_c/games/fallout/Fallout Fixt/FALLOUTW.exe"
In this case you have to apply the change also to the launcher in $HOME/.local/share/applications/wine to make it work correctly.

Enabling Custom Settings

The installer has one problem, the custom settings (GVARs) are not saved to the VAULT13.GAM, the file is located in /Fallout Fixt/DATA/DATA in your fallout game directory, if you chose the same directory I chose, that is $HOME/fallout/drive_c/Games/Fallout/Fallout Fixt/DATA/DATA. The values you need can be found in the install.log (/Fallout Fixt/DATA/FIXT). Simply open both files in a text editor, alter the values manually and you are done. To my knowledge that is all.
VALUT13.GAM
You can also copy the file from an existing Windows installation if you want to play with the same settings.

Known Issues

  • Fallout sometimes crashes on exit (black screen), if that happens switch to a virtual console (CTRL+ALT+F1), login and enter pkill FALLOUT, then switch back to the graphical interface with ALT+F7.
  • ALT+TAB does not work in Fullscreen mode (at least under Unity, others not tested so far).

Gameplay Tips

If you are playing Fallout for the very first time, some general tips for you

  • Fallout is not an action game, take things slow, explore the maps, try things out (you can always save) and see what happens.
  • Fallout offers a lot of possibilities besides fighting. Having at least one really high combat skill makes the game a lot easier, but having only high combat skills will do the opposite.
  • Fallout isn’t really well balanced, you might quickly run into situations that are difficult to handle for a low-level character. So, if you are not strong enough for a fight with a group of Raiders or a large pack of radscorpions: run. It’s about survival, not about killing.

And now it’s funtime!
Fun Time

Famous Last Words

Everything in this guide was tested multiple times. I also did a complete play-through using Fallout Fixt 6.7.3 and roughly half a play-through using Fallout Fixt 0.81. However, I cannot guarantee that on your Linux system something is not working, I also cannot guarantee that somewhere inside is a Wine-related bug. The game is large, Wine is a beast and Linux systems can differ.

A Wallpaper Randomizer for Openbox Based on Nitrogen

In this Article I want to show you, how you can build a simple wallpaper randomizer for the Openbox desktop using Nitrogen and some basic system tools. All you need to install is Nitrogen, the other tools should be available on your system.

What I wanted to create is a script that works seamlessly with Nitrogens GUI functions, so the script has to read from Nitrogens config files, so you can use the GUI to pick the directories. It should also be able to write to Nitrogens config files to allow Nitrogen to remember the currently selected (random) wallpaper.

Nitrogen

Nitrogen with the official Ubuntu wallpapers of the last couple of years

The script is mainly some playing with grep and sed and some regular expressions, it’s also an example how to use a pipe to chain commands.

The Basic Script

First we read the name of the current wallpaper from Nitrogens bg-saved.cfg file using grep with Perl regex

CURRENT=`grep -Po "(?<=file=).*" "$CONFIG/nitrogen/bg-saved.cfg"`

The command is written in backticks, that means that the output of the command is written into the variable. Then we use grep again using a similar Perl regex to get the full path to the files in Nitrogen’s source folders.

FILES=`grep -Po "(?<==).*" "$CONFIG/nitrogen/nitrogen.cfg" | sed "s/;//* /g"`

We use a sed to replace the semicolon separating the directories with /*.

Then we list the files using ls and search the output for images and count them

COUNT=`ls $FILES | grep -Eic ".*.(png|jpe?g|bmp)"`

It doesn’t make sense to randomly change two wallpapers, so we need to be able to avoid that. So we can make the rest of the script conditional (on the count). This way we also avoid (later) an infinite loop, when just one wallpaper is in the selection.

To select the new wallpaper we use basically the same code as before

NEW=`ls $FILES | grep -Ei ".*.(png|jpe?g|bmp)" | shuf -n 1`
while [ "$NEW" = "$CURRENT" ]; do
    NEW=`ls $FILES | grep -Ei ".*.(png|jpe?g|bmp)" | shuf -n 1`
done

To randomly pick a file from the list we use shuf. shuf is cool for anything random, need a d6 use shuf -i 1-6 -n 1, d20 shuf -i 1-20 -n 1. To avoid that the new wallpaper is the current one, we compare the two and in case they are identical we repeat the random pick until it is a different one.

Now we use Nitrogen to change the wallpaper

nitrogen --set-zoom $NEW && sed -i "s!^file=.*!file=$NEW!" $CONFIG/nitrogen/bg-saved.cfg

when that is done, we use sed again to change the entry in bg-saved.cfg, so nitrogen will know, about the new wallpaper. That is the basic script, you can get it from GitHub:
https://github.com/SvenPM/bits-and-pieces/blob/master/wallpaperrandomizer/nitrogenium-basic.sh

The Advanced Script

Random wallpaper with notification bubble

Wallpaper with notification bubble (that image is Stefanie Heinzmann in a promotional shot for her new album *Chance of Rain*)


As a more advanced feature, I added the a notification bubble using notify-send, that contains the name of the wallpaper as well as a thumbnail.

To create the thumbnail we use ImageMagick’s convert

convert "$NEW" -thumbnail 50x50^ -gravity Center -crop 50x50-0-0 "$CONFIG/openbox/thumb.png"

From the path of our new wallpaper we extract the filename (without the ending), I made a limit of 100 characters (that should be enough).

NAME=`echo $NEW | grep -Pio "[^/]*(?=.(png|jpe?g|bmp))" | cut -c1-100`

Then we use Nitrogen to change the wallpaper and create the notification bubble with notify-send and sed the change to bg-saved.cfg

nitrogen --set-zoom $NEW && { notify-send -t 5000 -i "$CONFIG/openbox/thumb.png" "Nitrogenium" "Changed wallpaper to "$NAME""; sed -i "s!^file=.*!file=$NEW!" $CONFIG/nitrogen/bg-saved.cfg; }

Afterwards we can delete the thumbnail.

This script is available on GitHub as well:
https://github.com/SvenPM/bits-and-pieces/blob/master/wallpaperrandomizer/nitrogenium.sh

The Auto-Changer

I also wrote a little script to run in the background and change the wallpaper automatically every 300 seconds. Some people use cronjobs for that but I am not happy with that solution. First it is unnecessarily complicated for beginners and second having script run in background gives me more control. If something goes wrong, I can simply kill it.

An easy solution is an infinite loop, while they can be pretty ugly, they do exactly what we need.

while true; do
    /home/$USER/.config/openbox/nitrogenium.sh &
    sleep $DELAY
done

As a delay I added 300 seconds (aka. 5 minutes), you can carnage that value, just don’t make it too short. I have made the script compatible with the screen saver/lock described in the previous post you can get also this one on GitHub as well
https://github.com/SvenPM/bits-and-pieces/blob/master/wallpaperrandomizer/auto-nitro.sh
if you don’t use the screen saver replace the while loop in the script with the one posted here.

Install

  • download the scripts you want and copy them to .config/openbox/ (if you want them in another directory, you might have to change the code)
  • make the executable using chmod u+x
  • run them.

You can run that scripts automatically or manually by adding a new entry for it to your menu.xl or assigning a shortcut in rx.xml. When you add it to your autostart add a short delay.

One last thing…

I hope you enjoy these scripts. They work pretty fine here but let me know if you have any problems, I will try to help. I also hope that nothing got lost during transfer to GitHub, WordPress unfortunately ate some of my code in the past, so I moved it to GitHub. So, please let me know, if there is something weird.

How to build a kick-ass screen saver/lock for Openbox

How to build a kick-ass screen saver/lock for Openbox

While experimenting with Openbox for BoxBuntu: Replacing Unity with Openbox, I tried to build my own screen saver based on gnome-screensaver but with more advanced features. It works pretty well, so I thought, I should share it. This might work for other window managers as well, I just didn’t find the time to test it on different WMs. My test system is still Openbox on Ubuntu 14.04.

What do I want?
– I want the screen to be locked automatically after a certain period of time of inactivity
– I want also to be able to lock it via shortcut (WIN+L)
– I want to be able to inhibit the screen saver by shortcut
– I want it to not kick-in when watching a video or running certain applications (Caffeine-like)
– I want it to switch off the screen, on the netbook that saves some power and also keeps it cool
– I want it to look good

How to do that? The first two points are easy, I showed you how to do it in the previous article. Let’s have a look at the rest.

Make it look cool

I started with the last point, making it look good. Well, as good as something static can be. I don’t want an animated screen saver, these days are over in my humble opinion. I found a pretty cool idea on the i3wm support site. It uses scrot to take a screenshot of your current desktop and use it as a background image for the screen lock. The Idea is not new, I remember such screen savers but the method is rather cool.

That doesn’t work the same way with gnome-screensaver but it can be done. I will provide the complete scripts later but I will explain the bits and pieces here. First lets take the screenshot and blur it a bit

screen1="/home/$USER/.config/openbox/lockscreen1.png"
screen2="/home/$USER/.config/openbox/lockscreen2.png"
# take screenshot
scrot $screen1
# pixelate and blur image using convert (could use mogrify but is slower)
convert $screen1 -scale 40% -scale 250% -blur 10x10 $screen2
# delete screen1
rm $screen1

Convert is part of ImageMagick, if ImageMagick and scrot are not installed, you can get them from repo. This chain of commands creates just the blurry picture, it gets downscaled by a factor of 2.5 and upscaled by a factor of 2.5 then smoothened with s strong blur effect.

clear desktop image

Original desktop look (wallpaper is Lorde, found somewhere on the web), you can see conky and Tilda being active

blurred desktop

Same screenshot done with above commands, you can still see what’s there but not identify details


But we cannot use it in the gnome-screensaver directly, it has no argument for an image, it simply uses the background used in the GNOME environment. We don’t use that, our wallpaper is done independently, but we can make use of it, using the same command, that is used by GNOME wallpaper changers (found it in Variety).

# make screenshot gnome background
gsettings set org.gnome.desktop.background picture-uri "file://$screen2" 2> /dev/null

Next we can run the screen saver

# lock screen using gnome-screensaver
exec  gnome-screensaver-command -l &

Lets put that together, create a script called locker.sh and make it executable. And instead of calling gnome-screensaver directly, we call this script. That will result in a login screen like this one

Login screen

Login screen with blurred screenshot as background (showing the desktop with conky)


So, unless you have some really naughty stuff on your screen there shouldn’t be any problems with privacy, as you can see with conky, there is nothing readable. Here is another example with Nemo open.
Login screen

Login screen with blurred screenshot as background (showing Nemo)

Save energy

To switch off the screen, we use xset dpms to enable energy saving mode, you can use xset dpms force off to switch off the screen immediately. That is not a very friendly solution, I tried to workaround that. But let’s go step by step.

First I added a little delay, just in case you want to login immediately, you can adjust that delay to your liking.

# lets wait a bit before switching off the screen
sleep 10

Now we check if the screen saver is already inactive (meaning you logged in) using gnome-screensaver-command -q, if not inactive, we switch off the screen, if it is inactive, we end the script.

# next lets get the state of the screen saver, if still active, switch off the screen
bla="The screensaver is inactive"
state=`gnome-screensaver-command -q`
if [ "$state" != "$bla" ]; then
    # turn off display
    xset dpms 0 0 1; sleep 2
    # make display turn off automatically after 20 sec
    xset dpms 0 0 20
else
    exit
fi

I use two commands for xset dpms, the first one sets the poweroff delay to 1 second, then I added a delay of 2 seconds (so unless you do something, the screen gets turned off after a second) before changing the poweroff delay to 20 seconds. That way I avoid, that the screen gets turned off while you try to login, which would happen when you use force off. I know, I could have done it easier but I like it this way, a little gambling.

No we let the script run in background and check the state of the screen saver, basically, it does nothing, most of the time it sleeps, so don’t worry. We need to do that because with xset dpms 0 0 20 the screen will switch off every time you are inactive for 20 seconds or more, that is certainly not desirable. We need to run xset dpms 0 0 0 to switch that off, after the screen saver was disabled.

# lets keep the script running in background until the screen saver gets switched off
# in other words: until you login.
while [ "$state" != "$bla" ]; do
    sleep 5
    state=`gnome-screensaver-command -q`
done
# set display to not turn off automatically
xset dpms 0 0 0

We add that code in the end of locker.sh.

Inhibit the screen saver

This is similar to the caffeine application used in Unity, that’s why I called parts of the script cappuccino.

Disable the screen saver when media players are running

That part is fairly easy, we read the processes running for the current user using ps -u $USER and pipe the output to grep and count the media players with a regex, and value larger than zero exits the script. So we add th following to the beginning of locker.sh.

# inhibit screensaver when mediaplayers are running
# cheap method, add missing players to regex
if [ "$1" != "-f" -a `ps -u $USER | grep -Ec "(totem|mpv|vlc|*mplayer)"` -gt 0 ]; then
    exit
fi

pretty cheap but works. Why the "$1" != "-f"? $1 is an argument that can be passed to the script, like the switches you know from terminal commands. This way you have the possibility to force (-f) the screen saver manually and bypass the inhibitor functions (manual actions should always win).

Disable the screen saver manually

This requires a little helper script that I called cappuccino.sh

if [ -f "/home/$USER/.config/openbox/cappuccino" ];
    then rm -f "/home/$USER/.config/openbox/cappuccino" && notify-send "Cappuccino" "Screen saver enabled"
    else touch "/home/$USER/.config/openbox/cappuccino" && notify-send "Cappuccino" "Screen saver disabled"
fi

What does it do? It checks for a file called cappuccino in your Openbox config folder. If it is not there it creates it, if it is there, it deletes it. In other words, the script toggles the existence of that file. We can map that script to a shortcut in rc.xml, I used CTRL+WIN+C (C-W-c). It uses notify-send to display a notification bubble.

Cappuccino

Cappuccino notification. For the icon I added `-i caffeine`

Now we need to add the following to locker.sh to check for cappuccino

# inhibt screensaver use -f switch to bypass
if [ "$1" != "-f" -a -f "/home/$USER/.config/openbox/cappuccino" ]; then
    exit
fi

Again we can bypass the inhibition by forcing the screen saver to be switched on.

Put it all together

  1. Check if you have gnome-screensaver, scrot, imagemagick and notify-send installed (in case you don’t know how, just search them in Synaptic), on *buntu you can install them from repo. For other Linux ditros they should also be available. If you have something other than notify-send in your distro, exchange that part or remove it.
  2. Copy the two scripts into an empty text file (each) and save them to .config/openbox/, then make the files executable using chmod +x (both). Try to run the scripts and see if they work.
  3. apply the changes to rc.xml and autostart.
  4. logout and back in and see if the screen saver works.
  5. adjust the script to your liking.

Done!


Famous last words

I am using this screen saver/lock for a few days without any problems, so I think it is safe to use. If you have any problems or additions or find bugs, let me know. If you login to a Unity or GNOME session, the background might look odd.

Feel free to modify and distribute these scripts, just don’t forget to give credit. And drop me a note, I am curious what others are doing with this.

BoxBuntu: Replacing Unity with Openbox

BoxBuntu: Replacing Unity with Openbox

Difficulty Level: a bit advanced, you should at least be comfortable with editing config files manually.

This was done on Ubuntu 14.04 but should work in a similar fashion in other *buntus or Linux distros.

While I really like Unity on my desktop computer, it is a bit heavy on the netbook. So I was looking for an alternative. Xfce and LXDE are cool but they bring a lot of applications that I don’t like or want. The solution to the problem is a window manager. In contrast to a desktop environment a window manager contains just the “frames” for the applications but in itself no applications.

My window manager of choice is Openbox, it’s small, it’s light and it comes with nothing, logging into a new Openbox session you end up with an empty desktop with no clock, no taskbar, no widgets, there is just the menu, called root menu.

That is not very cool, huh? Well, actually, it is pretty cool, cause you can add the missing components yourself. Making your desktop your living room and creating your own desktop environment from the components you prefer. And Openbox can look pretty cool, if you look at distributions such as Crunchbang.

My netbook is an Acer 1215b EeePC with an 1.65 GHz AMD APU, 6 GB of RAM, a 500 GB HDD and a 1366×768 display. It connects to the internet via a Huawei surfstick. So that is the setup I designed my own “desktop environment” for.

Note: If not otherwise mentioned, packages were installed from official repo.

What is Openbox?

As said, Openbox gives you just the “frames” to your applications, so an application in an Openbox desktop will have the buttons to close and minimize them in a title bar and they will be drawn over each other and placed on different workspaces. It offers you the possibility to add shortcuts to various actions. And you can apply themes to the windows. Openbox also has something like a start menu which is completely customizable.

Customization in Openbox is done via three simple text files, one controls the window layout, mouse actions and shortcuts (rc.xml), one the menu (menu.xml) and and the last one the autostart applications (simply autostart). You find example files in /etc/xdg/openbox/, copy these files to .config/openbox/ in your home directory to edit them.

rc.xml and menu.xml are (surprise) XML files, so if you know other XML based config files or a little (X)HTML, the syntax should be clear. Have a look at the examples in the default file, they are very helpful.

The autostart is basically a shell script that contains the packages and scripts you want to load/execute on login, which can be virtually everything. The syntax is so, that the script just fires up the commands virtually at the same time (the & in the end), so you have to be careful to not execute too many commands at the same time, so best combine them with a delay (sleep command), if they do not play nice.

You also get some GUI apps to adjust some settings, obconf controls the appearance and obmenu the menu entries (however, I didn’t get obmenu to work on Trusty on two systems). There is also obkeys available on GitHub to adjust the shortcuts. However, I preferred to edit the text files directly.

While you can already get pretty far with that, you can add more layout and functions to it.

How to make Openbox be cool?

BoxBuntu

My “BoxBuntu” setup with tint2, conky, and tilda. I use Dorian Dark 3.10 (GTK) and Dorian Neon (Openbox) theme, zoncolorDarkGrey icons, PolarCursorTheme-Blue and my favorite Lykke Li wallpaper.

A Composite Manager

First you should add a composite manager. On Unity that is done by compiz but that is pretty heavy, using quickly a few hundred MB, we don’t want that. A lighter approach is Compoton (later versions available from ppa:richardgv/compton), a fork of xcompmgr. With Compton you can add real transparency and shadows. You can simply add compton to the beginning of your autostart file

# Start composite manager
compton -b &

There is also a configuration tool available called compton-conf (you can get it at ppa:joern-schoenyan/lxqt). Changes done via compton-conf won’t be visiable until you restarted the session (log in and out).

A Taskbar

tint2

tint2 with two workspace, one running Pale Moon (active) the other one DeaDBeeF (inactive), a system tray and a clock


Next thing to add is a taskbar, I installed tint2. It’s also a very light application, that can, besides the taskbar also work as a workspace switcher/pager, system tray and clock. tint2 is like Openbox controlled via a simple text file and you can adjust virtually everything. To start it, you simply have to add it to your autostart file.

## add the taskbar
tint2 &

I have grabbed the latest version from vivid repo, since it addresses a few bugs. Sometimes tint2 doesn’t play nice with the composite manager, if you have that problem, add a short delay like

## add the taskbar
(sleep 10 && tint2) &

If you want something more advanced you might want to try Xfce4-panel or lxpanel but I find tint2 pretty charming.

An Application Launcher

gmrun

Trying to launch Pale Moon in gmrun


A very simple one is gmrun. It basically does the same as ALT+F2 in Unity. It’s main features are a history and autocompletion via TAB. You can add it as a run dialog to the menu and map it to ALT+F2 (I have it at WIN+Space) in rc.xml. There is no need to add it to autostart, it starts, when it is needed

    <keybind key="W-space">
<!--    <keybind key="A-F2">-->
      <action name="Execute">
        <command>gmrun</command>
      </action>
    </keybind>

I have also added the following to the applications section to make gmrun be always on top and to not appear in the taskbar.

    <application name="gmrun">
      <layer>above</layer>
      <focus>yes</focus>
      <skip_pager>yes</skip_pager>
      <skip_taskbar>yes</skip_taskbar>
    </application>

A Start Menu

openbox-menu

Launching applications using openbox-menu


While I am usually using gmrun to launch applications, I sometimes like to have a start menu, that can be created using so called pipe menus in your Openbox menu with the commands openbox-xdgmenu or openbox-menu, the difference is that openbox-menu can do icons but that is fairly slow on a week machine like my netbook, without the icons I don’t see a difference. Try both of them and see what works best, just add it to your menu.xml.

<menu id="desktop-app-menu"
      label="All Applications"
      execute="openbox-xdgmenu /etc/xdg/menus/gnome-applications.menu" />

A Screensaver

Well, actually, nobody needs a screensaver these days but what we need is lock for the screen when we are not there. Since it is already on board you can use gnome-screensaver by simply adding it to your autostart file. But that alone does nothing. You also have to enable it, this can be done in multiple ways. One is a shortcut, so map something like WIN+L to gnome-screensaver-command --lock.

    <keybind key="W-l">
      <action name="Execute">>
        <command>gnome-screensaver-command --lock</command>
      </action>
    </keybind>

But that requires you to do something, you can also add autolocking. That is done through xautolock. To enable that, you have to put it in your autostart.

# Start screensaver
gnome-screensaver &
# enable autolock
xautolock -time 3 -locker "gnome-screensaver-command --lock" -corners +0-0 -cornerdelay 5 -cornerredelay 5 -detectsleep -secure &

The -corners part activate or inhibit the screenlock by placing the cursor in the corners of your screen (see man xautolock for details). In the example I use 3 minutes of inactivity to lock the screen, the active corner are left (top to lock after a few seconds, bottom to inhibit locking).

In one of the next posts I will show you something that looks more elegant and provides more functions (locking the screen, shutting off the display, inhibit screen lock when media players are running, etc.).

EDIT: How to build a kick-ass screen saver/lock for Openbox

A Logout Dialog

lxsession-logout

lxsession-logout dialog box


You will notice that by default, there is no grapical way to log out of your Openbox session. this can be done using lxsession-logout. Add it to your your menu and/or map it to your power button (the latter might be a little tricky), for me this worked

    <keybind key="XF86PowerOff">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>Logout</name>
        </startupnotify>
        <command>lxsession-logout --prompt="Leave BoxBuntu?"</command>
      </action>
    </keybind>

A System Monitor

While not absolutely necessary, it is nice to have, my choice is conky, it will also benefit from Compton, if you add transparency. conky is in fact a topic for itself, or simply look around, there are a lot of conky configurations available, use them or adjust them to your liking.

conky

Conky displaying some system info


In case these is interest I can also upload my conky configuration file.

A Battery Indicator

For mobile computers it is absoluty necessary to know how much power is left. You can add that function to conky but conky gets hidden by other apps, Would be cool to have an indicator in the system tray, you can do that by installing XFCE4-power-manager. I would have preferred to use gnome-power-manager but didn’t manage to get it working.

Wallpapers

What is a desktop without a wallpaper? Right, boring. To manage wallpapers, we can make use of Nitrogen, it’s a very simple wallpaper manager and perfectly fine for a lightweight desktop. Nitrogen needs to be added to your autostart files. All you can do is specify folders and select wallpapers from them. You can also make it restore your previous wallpaper by adding it to your autostart file.

# add wallpaper
nitrogen --restore &

To change the wallpapers you can use the Nitrogen dialog

Nitrogen

Nitrogen with the official Ubuntu wallpapers of the last couple of years


You could also use feh, it is described in many tutorials, but I find Nitrogen easier to use.

EDIT: if you want something more advanced, try my wallpaper randomizer based on Nitrogen.

Some Tweaks

One really cool tweak is unclutter. unclutter hides your cursor after a certain period of time, so it wont disturb while you are reading or typing. As soon as you use the mouse or touchpad it reappears. It just has to be added to autostart

# Hide mouse pointer
unclutter -idle 10 -root -jitter 10 &

adjust the idle value to your liking.

In case you have problems with screen brightness, you an use xrandr to adjust it on login by adding it to your autostart

# adjust screen brightness
xrandr --output LVDS --set BACKLIGHT 3 &

You might want to adjust the BACKLIGHT value to your liking, 3 works nice for me.

Another great application is lxappearance, it is part of the LXDE project and allows you to easily change the GTK theme and the cursor theme. It nicely complements obconf and compton-conf.

lxappearance

Selecting an icon theme in lxappearance

Applications

  • I use gedit as my text editor (enable pkexec for gedit). It is comparably heavy but we have saved enough power for it, and it is a pretty powerful tool. You could also go for Mousepad, if you want something lighter.
  • Tilda and sakura are my terminal emulators. Tilda replaces Guake in this setup, its handling is pretty similar and Tilda is much smaller, also it plays well with Openbox (in contrast to Unity). You can install a more recent version from the vivid repo. And I simply like sakura, the handling is pretty sweet.
  • My file manager is Nemo, it is also rather heavy. If you want to use it, install the version without Cinnamon dependencies. You can also use Nautilus (or whatever comes with your *buntu), GNOME Commander or Midnight Commander (I recommend to install the latter anyway).
  • For package management, I recommend Synaptic (or use the terminal) because it is simple and easy to use.
  • For clipboard management I use ClipIt, Diodon, Parcellite or many others would work as well, choose depending on your liking.
  • As a music player I installed DeaDBeeF, I prefer Quod Libet on the desktop but DeaDBeeF is lighter and for mobile use perfectly fine. The collection of music is simply smaller.
    DeaDBeeF

    DeaDBeeF in Openbox

  • Pale Moon is my default web browser, it is overall a bit lighter than Firefox (not that it is really light, none of the larger browsers is, if you want something lighter try Midori). Also the icon fits my overall style better.
  • Searchmonkey is used to search in files (grep-like), an alternative would be the also pretty light regexxer. Both have their benefits and weaknesses, choose what you like.
  • To search files (find-like) I installed catfish.
  • To compare files Meld works just fine.

That is the stuff I actually use on a regular basis. For videos (rarely watch them on the netbook) I use mpv, for office stuff I kept LibreOffice.

Themes used

I am using Dorian Theme 3.10 (with matching Openbox theme called dorian-neon) by Josh Brown (hellokitten/killhellokitty), zoncolorGreyDark icons by Zon Saja, PolarCursorTheme-Blue by Eric Matthews (ECHM) and the Ubuntu fonts. The overall color theme consists of black white and blue which are also present in conky and tint2 as well as the terminal emulators.. I also used the bluish tone for the shadow. I have also added some transparency to the titlebar, menus and inactive windows, the letter ones are also get dimed. The current wallpaper is Lykke Li (from a fashion campaign for Lykke Li & Other Stories, wallpaperized by me).

Links

Many tutorials are slightly outdated but you can still use parts of them.
Openbox
– The Openbox Wiki
– The Openbox configuration guide and Adding CrunchBang features in another distro on Crunchbang Wiki
– The Openbox article on Arch Wiki
Install Openbox On Ubuntu 13.04 & 13.10 by Rob, got my basic setup there
Openbox guide and Openbox FAQ from urukrama’s weblog

The tools
– for info on tint2 check the tint2 Wiki
– for info on conky check the conky documentation

Some Eye Candy
Box Look is a nice source for stuff related to various window managers including Openbox.
GNOME Look contains a lot of stuff for the GNOME based desktop, some themes include Openbox themes, cursors and wallpapers are universal.
KDE Look same as above for KDE

Closing Words

That turned out to be a long one here but it was fun to write and at least I have a guide, if I should ever need to reinstall it. I have been using this setup for a couple of days now and it feels pretty good. RAM and CPU usage decreased notably, fan noise dropped, applications run faster. I still try to open Dash from time to time and look in the upper right corner for the clock. But one can get used to it. How much work is it? To get it running I think you might need a weekend, I needed four days (evenings) including writing this article and trying a couple of alternatives (and doing some scripting). If you want to try, start with the stuff from Rob’s tutorial (in the links) and replace the outdated stuff with my suggestions.

And if you tried, let me know and send screenshots :)

Changing the Clock Display in Unity

Difficulty level: very easy

Usually Unity’s clock displays the time in a local format. Via the Clocks tab in Time & Date Settings you can add seconds, the current date, the year and a few other things.

Date & Time settings

Date & Time settings

That is cool but limited. In this post I want to show you, how to adjust the clock to use a custom format.

I prefer to have dates displayed in ISO 8601 format, thats four digits year, two digits month, two digits day, or in short YYYY-MM-DD. Why? Bevause in contrast to local formats, like DD.MM.YYYY or MM/DD/YYYY, it is sortable in a logical way. That’s why I use it in applications and I also want the time on my desktop to be displayed the same way.

Unity clock

Time in ISO 8601 format

How to do that in Unity?

First you need to make sure you have dconf Editor installed, if it is not installed use sudo apt-get install dconf-editor or install it via Synaptic or Software Center if you are still afraid if the terminal.

When installed, start if from Dash. The amount of settings in dconf Editor is pretty large, you should not change settings that you do not know. The settings for the clock can be found in com->canonical->indicator->datetime, you can easily get them by using the search (CTRL+F) and searching for datetime.

dconf Editor

datetime settings in dconf Editor (before)

In the list of options you find (almost the last one) time-format, the default setting is ‘locale-deafult’, change that one to ‘custom’ (clicking the value displays a list with options).

dconf Editor

Changing time-format

Next we have to change the format, this is done by changing custom-time-format (at the top of the list) to ‘%F %T’.

dconf Editor

Changing custom-time-format

The display will change immediately, no need to reboot or logout and back in.

dconf Editor

datetime settings in dconf Editor (after)

%F is short for %Y-%m-%d, %T is short for %H:%M:%S. To find out more about these settings, use man strftime.

GUI-style Applications for the Terminal – Part 1: Nano

On Linux you have a couple of really advanced applications that run inside the terminal, very similar to the ones you know from the graphical interface. In this series of posts I want to introduce a few of them. The advantage of these applications is, that you can use them even when you cannot get into a graphical interface, so they also make up some great rescue tools, but getting used to them when you don’t have to use them is not a bad idea.

In fact you get a lot of GUI-style applications designed for use in the Terminal, web browsers, chat and email clients, games and even media players. In the first part of this series I want to introduce Nano which is a standard component on many Linux/Unix systems, on your *buntus you will surely find it.

What is Nano?

nano

The Nano text editor showing .nanorc


Nano is a simple text editor similar to gEdit, Leafpad, Mousepad, Kate or Notepad on Windows. It’s for editing text based files (e.g. scripts, configuration files) not a text/word processing software like Libre/OpenOffice Writer or Microsoft Word. It is not amazingly rich in features but in contrast to other terminal based text editors like vim or Emacs it is really simple to use for beginners and for all kinds of simple tasks it is more than good enough.

It’s layout is pretty similar to the one of text editors you might already know. You find the standard functions on the bottom of the screen, more will be displayed if you open the help. What I find a bit irritating for beginners is that the names of the commands are a bit weird, so it is “Where is” instead of “Search” or “WriteOut” instead of “Save”. Also the standard shortcuts are pretty different from the ones you are used to and some of the shortcuts are terrible complicated to perform when you do not have an English keyboard, fortunately, many functions have more than one shortcut.

One great feature is that Nano offers support for syntax highlighting, so it is also an alternative to less and more when it comes to reading scripts. The definitions are at times incomplete or maybe old, but they are available for many different languages (Perl, Java, bash, Ruby, Python, HTML, CSS) and still it is better than heaving no syntax highlighting.

nano

A simple Perl script in Nano


For this screenshot I had to add chomp and say to perl.nanorc.

Using Nano

The use is really simple, the command to start it is nano (surprise, surprise), by default it will also start when you hold CTRL and press X and E. If you want to open a file in Nano you can add it as an argument (yes, auto-complete with TAB works here too, nano is an ordinary command), looking like that
nano test/test.txt
It is particularly helpful when you have to edit files outside of your home directory, cause you can simply run it as root without breaking something
sudo nano /etc/fstab

You often find that shortscuts are written with a caret (^) in the beginning, that is for CTRL, so ^G to open the help is CTRL+G. But it also means that you can hit ESC twice and then the key, like ESC->ESC->G. Other shortcuts have M- in the beginning, this means that you have to use the ALT (or META) key, so M-D means ALT+D, you can also use ESC her by using ESC->D.

Talking about ^G, the help system of Nano is fairly good cause there are help texts available for every screen and the shortcut is ways the same. You can also use F1 instead of ^G (unless it opens the help of the terminal application you are using).

Most often you will do something simple with the test that is displayed, like changing some values. To save a file you have changed can use the “WriteOut” command performed by ^O (that’s an O like Oscar) or F3, the file name input supports autocomplete using TAB (as well a suggestions using TAB twice). When you close a file that you modified using ^X, it will also ask you, if you want to save the changes.

Nano can perform actions like cut, copy and paste but they are pretty different from what you know from graphical text editors. You first have to set a mark using M-A, than you can mark the test using the arrow keys. Using ^K you can cut the text M-6 copies it. To paste you have to use ^U to uncut. If you use M-6 or ^K it will cut/copy the entire line of the cursor position.

Copying text from a GUI application (your browser) into Nano is not that easy, CTRL+SHIFT+V or primary selection don’t work. When you run Nano for example in the gnome terminal you can at least use paste from the terminals Edit menu or the right-click mouse menu.

One of its more advanced features is – besides the syntax highlighting – the search which supports regular expressions. To open the search you use ^W, then enter the pattern you wan to search, use M-R to use regex. The cursor will jump to the text matching the search pattern. Use M-W to jump to the next match. There is even a history of search patterns that you can access using ^P (Previous) and ^N (Next) or the up and down arrow keys, however, the search doe not member the type of pattern. It also can do search and replace using ^R.

Nano

Using regex search in Nano

To customize the behavior of Nano, you have to edit nanorc, it is located in /etc/, best copy it to your profile using cp -vi /etc/nanorc ~/.nanorc and then edit it using nano ~/.nanorc. If the file is present in your home directory, that one will be sued instead of the global one in /etc/. A full list of options can be found using man nanorc, this also includes the commands to change the key bindings and enable limited mouse support (requires the gpm package to be installed to use it in the virtual console, in case it is missing use sudo apt-get install gpm). Nano also supports an (experimental) Undo function, that you can activate, this changed with the recently (March 2015) released version 2.4, in which Undo is activated by default. But 2.4 is not available in recent *buntus.

Alternatives

As an alternative for Nano, you have only a limited version of vim pre-installed but without any knowledge vim is hardly usable. So, from that point of view there is virtually no alternative for you in case you have nothing else installed.

Amongst the text editors you could install are the likes of Emacs but while being pretty powerful that one is also not the most beginner friendly piece of software. A maybe lesser know alternative is mcedit (part of the Midnight Commander which I will introduce in one of the following posts), its handling is pretty similar to Nano, maybe even a bit simpler to use cause it looks a little more like the programs you are used to and it has a really nice set of features that makes it a real alternative to some of the lighter GUI text editors like Leafpad.

TL;dr

Nano is a comparably easy to use text editor for the terminal. It’s outstanding features are besides its simplicity the syntax highlighting and it’s rather strong search function. For beginners I would always go for a graphical text editor like gEdit or Kate or a small IDE such as Geany when you want to get into more advanced scripting or larger CSS/HTML files, however, there is no need to avoid the use of Nano when it comes to simple tasks such as doing slight changes to a config file or script. And I strongly encourage you to use it for that, there might be a time when Nano is the only option you have and than it is good, when it is not a completely alien piece of software.

Windows style three-finger-salute on *buntu

Difficulty level: almost too easy

CTRL+ALT+DELETE is maybe one of the most hated keyboard shortcuts on Windows (home user) systems. On *buntu systems (GNOME based systems) it just displays the logout/shutdown/hibernate dialog, which is not very helpful. But there is no easy way to open the system monitor, which you might need to use on Linux too. How to change that?

Open your System Settings and choose the Keyboard. In the Keyboard dialog open the shortcuts tab and open the custom shortcuts. Click the + symbol and create a new shortcut. The name should be something like “System Monitor” and the command is gnome-system-monitor, next click on Apply. This only creates the shortcut entry, it is still marked as disabled.

Create a shortcut for gnome-system-monitor

Create a shortcut for gnome-system-monitor

To enable the shortcut click on the “Disabled” text, the display will change to “New Accelerator…”. Now simply hit CTRL+ALT+DELETE, since the shortcut is already in use, a warning will be shown, click on Reassign.

Warning message when assigning CTRL+ALT+DELETE

Warning message when assigning CTRL+ALT+DELETE

That’s it, really, no need for the terminal. Try it.

This way you can assign other keys to Windows style functions as well, like WIN+E (on Linux that is called SUPER+E) to open your file manager.