Install VirtualBox Guest Additions in Ubuntu 14.04 Alpha via package system

I’ve been recently running Ubuntu 14.04 Daily Build using VirtualBox. Everything has been working great so far. However, after some large system upgrade involving a new kernel and a bunch of the xorg libraries, the customary re-installation of the VirtualBox Guest Additions modules stopped working for me. After several attempts, I was getting a message like this:

Warning: unknown version of the X Window System installed. Not installing X Window System drivers.

I googled around and I found a very useful thread in ubuntuforums.org that gave me the answer. So the steps that finally resolved this issue were:

  1. Remove the existing Guest Additions using the script under /opt:
    $ /opt/VBoxGuestAdditions-4.3.6/uninstall.sh
    

  2. Install the Guest Additions Iso using the package system
    $ sudo apt-get install virtualbox-guest-additions-iso
    

  3. Enable VirtualBox Guest Service driver, using the software-properties-gtk dialog.

    You can type the following command in the terminal to bring up the dialog.

    $ software-properties-gtk --open-tab=4
    

    wpid-software-properties-gtk-tab4.png

  4. Reboot

    The guest display can now be auto-resized, made full screen, etc.

Update 13/02/2014:

  • From today, this solution appears to be broken. Presumably, the latest upgrades pushed to the 14.04 repos have somehow broken it, most likely temporarily. I’ll update again this post if I find it working again. But in the meantime, you’ve been warned! :-)

Update 15/02/2014

  • As it turns out, there is a test build of the Guest Additions iso (v4.3.7) that installs without problems and fixes the issues. Thanks to AnimeMuyou and Martin for pointing this out (look for the links in the Replies section).

Upgrading Ubuntu 12.04 Desktop to the latest LTS enablement stack

The ATI Radeon HD 5770 graphics card on my main desktop computer died recently after months and months of noisy overheated operation (not a gamer myself, the dust is the one to blame here). So I’ve recently upgraded the GPU and unfortunately, I also had to reinstall Ubuntu 12.04. After many failed attempts, I was unable to make the card work with the existing graphics stack (tried different versions of the AMD proprietary driver with no luck). Fortunately I have a separate /home partition, so reinstalling Ubuntu is not that much of a pain.

So I decided to re-install the system and I downloaded a fresh 12.04 image from Ubuntu’s website. Soon after the installation completed, I noticed that the new Ubuntu image came with an updated Linux kernel, one from the 3.5 series instead of the normal 3.2 that I was used to see on my old Ubuntu 12.04 installation. I doubled check with my laptop’s 12.04 install, and effectively, there I can see a 3.2 kernel.

It seems that Ubuntu is shipping its newer Ubuntu Desktop images with updated Linux kernel and X stacks, what they call the “LTS Hardware Enablement Stack“. This is happening since the 12.04.2 point release. Point releases 0 and 1 shipped with a 3.2 kernel. So if you have an old 12.04 LTS installation , any upgrades applied via the update-manager or apt-get will only ever install kernels from the 3.2 series.

It turns out that this is a policy that they plan to continue with in future 12.04 point releases, where the kernel and X stack will be aligned to the latest Ubuntu available at the time.

However, in order to get these newer kernels you either need to install a system from a 12.04.2+ image or alternatively, opt-in by manually running the following command that will upgrade your installation to the quantal enablement stack (the latest at the time of writing).

$ sudo apt-get install linux-generic-lts-quantal xserver-xorg-lts-quantal

In case anyone wonder, the fresh Ubuntu 12.04 installation fixed the problem I was experiencing with the graphics. But to be completely honest, I still don’t know exactly why it did.

Source code browsing using GNU ID and Emacs

Source code comprehension programs are amongst the most important tools that every software developer needs to master. Using these tools in an integrated way from the comfort of you favourite editor is important to minimise the context switches that kill the developer’s productivity (you know, “the zone…”).

Here it is a short HowTo on how I use GNU ID Utils from Emacs. This assumes some Linux/Debian derivative (in my case Ubuntu 12.04) and a C/C++ project, but other languages like Perl or Java are also supported by GNU ID.

Verify that the id-utils Debian package is installed

$ dpkg -l | grep id-utils
ii  id-utils  4.5-3  Fast, high-capacity, identifier database tool

Alternatively, install it

$ sudo apt-get install id-utils

Download idutils.el and put it somewhere in your Emacs search path

The idutils source distribution comes with idutils.el, an Emacs interface to gid, the utility that comes with idutils and that let’s you query the ID database from the command line. At the time of writing, 4.6 is the latest version of the idutils package. However, it probably is safer to use the idutils.el from the same release as the idutils package installed on your system (in my case that is 4.5).

$ cd ~/temp
$ wget http://ftp.gnu.org/gnu/idutils/idutils-4.5.tar.xz
$ xz -d idutils-4.5.tar.xz
$ tar xvf idutils-4.5.tar
$ cp idutils-4.5/lisp/idutils.el "somewhere where emacs can find it"

Update your Emacs config

Add the following to your dotemacs file:

;; Emacs GNU ID utils interface
;; M-x gid to run the command
;; more info at http://www.gnu.org/software/idutils/manual/idutils.html
(autoload 'gid "idutils" nil t)

Build the ID database

The next step is to run mkid to build the identifier database. The following commands will produce an ID file in you project’s root directory. This will index your system headers as well as your project’s source code. E.g.:

$ cd "your favorite project"
$ mkid -s /usr/include/ .

Run gid from within Emacs

Open up any source file from your project, point your cursor at some identifier and run M-x gid. Emacs will ask you something like this:

Run gid (with args): thread_mutex_create

Just hit enter and Emacs will bring up a *compilation* buffer with the results:

-*- mode: gid; default-directory: "/home/juanrubio/3rdparty/icecast/src/" -*-
Gid started at Wed Apr 10 12:57:01

gid thread_mutex_create
thread/thread.h:104:#define thread_spin_create(x)  thread_mutex_create(x)
thread/thread.h:111:#define thread_mutex_create(x) thread_mutex_create_c(x,__LINE__,__FILE__)
thread/thread.h:136:# define thread_mutex_create_c _mangle(thread_mutex_create)
auth.c:683:        thread_mutex_create (&auth->lock);
cfgfile.c:94:    thread_mutex_create(&_locks.relay_lock);
connection.c:147:    thread_mutex_create(&move_clients_mutex);
format_mp3.c:122:    thread_mutex_create (&state->url_lock);
global.c:45:    thread_mutex_create(&_global_mutex);
slave.c:139:    thread_mutex_create (&_slave_mutex);
source.c:106:        thread_mutex_create(&src->lock);
stats.c:134:    thread_mutex_create(&_stats_mutex);
stats.c:138:    thread_mutex_create(&_global_event_mutex);
stats.c:864:    thread_mutex_create (&(listener.mutex));
util.c:719:         thread_mutex_create (&localtime_lock);
xslt.c:101:    thread_mutex_create(&xsltlock);
yp.c:282:    thread_mutex_create (&yp_pending_lock);
net/resolver.c:41:#define thread_mutex_create(x) do{}while(0)
net/resolver.c:206:        thread_mutex_create (&_resolver_mutex);
thread/thread.c:164:    thread_mutex_create(&_threadtree_mutex);
thread/thread.c:165:    thread_mutex_create(&_library_mutex);    

Gid finished at Wed Apr 10 12:57:01

The results can be navigated with the usual Emacs commands M-x next-error and M-x previous-error, (usually assigned to M-g n and M-g p)

Similar tools

There are a number of other source browsing/navigation tools that are specific for Emacs or that also integrate well with Emacs, some of them are:

Thanks to Ubuntu’s Unity

With the advent of the Unity shell in Ubuntu 11.04 (Natty) and the Gnome 3 shell in 11.10 (Oneiric), I and, I believe, many other Ubuntu users, started to look around for a window manager replacement that we could use to continue doing development work properly and without feeling that our productivity was compromised.

This is how I came to know the Awesome Window Manager. I really thank Ubuntu for shipping that painfully slow version of Unity in April 2011. The adoption of Awesome has been the most productive change in my developer work-flow since I discovered Emacs org-mode back in 2007.

./awesome.png

What is Awesome WM

Awesome falls into the category of tiling window managers. The project was started in 2007 by Julien Danjou, who according to Wikipedia, started it as a fork of dwm, another tiling window manager. For hard-core Emacs users, Awesome is probably one of the best choices of window manager out there. Simply because the window manager keyboard shortcuts do not interfere with those from Emacs and actually seem like a natural fit for people like me that like to have complete control from the keyboard with a minimal use of the mouse.

Pros/Cons

This is a very personal summary of what things I like and dislike about Awesome WM.

Pros:

  1. Very minimal, no clutter, tiny top panel that stays our of your way and maximises screen real state.
  2. Large number of workspaces (a.k.a ‘tags’ in Awesome WM speak). The default is 9.
  3. Very stable. Almost two years of daily use, and I don’t remember it crashing on me or having to restart it. One of the advantages or being minimalistic.
  4. High performance (this WM is really minimal), switching between workspaces/windows with 0 lag; the desktop loads immediately after the login screen (because there’s not a lot to load really). No silly 3D effects. It is perfect for running on virtual machines.
  5. Default keyboard shortcuts do not interfere with (my) Emacs key bindings thanks to Awesome using the Windows key as trigger.
  6. Everything can be done from the keyboard. Jumping between workspaces, selecting windows (a.k.a ‘clients’ in Awesome WM speak), transferring windows to other workspaces (a.k.a. ‘tags’ in Awesome WM speak), switching between tile layouts, changing window positions and sizes, starting terminals and programs, closing windows, putting windows on top, maximising, minimising, etc.
  7. No hassle installation in Debian derivatives with sudo apt-get install awesome.
  8. Minimal/no configuration out of the box that gets things working from minute 0. Multiple screens work out of the box at least in Ubuntu.

Cons

  1. Additional configuration/personalisation requires tinkering with Lua scripts, which I don’t mind since I don’t care about the looks of the desktop.
  2. You need to memorise a basic subset of keyboard combinations from day 1. Not a problem if you are an avid Emacs user like me.
  3. No volume widget. Keyboard multimedia keys do not work out of the box (more on that later).

Keyboard shortcuts

This is the subset of the window manager shortcuts that I use most frequently, and that I believe are minimal to be productive in this type of environment (NOTE: Mod4 is the Windows key on a normal PC keyboard).

 
Starting/closing things Function Comment
Mod4 + Return Spawn terminal This is so intuitive you will want to do it in other window managers
Mod4 + r Run command A tiny command prompt appears at the top panel near the left corner
Mod4 + Shift + c Close focused window Need to be careful as sometimes it is difficult to discern which one is the focused window
 
Maximixing/Minimizing Function Comment
Mod4 + m Maximize/restore windows Ditto
Mod4 + n Minimize windows Ditto
Mod4 + Ctrl + n Restore a minimized window This one takes a bit of time to remember as it is not so intuitive
Mod4 + f Set window full screen The window is all over the screen, the top level panel disappears
Mod4 + t Set window on top Ditto
 
Workspaces Function Comment
Mod4 + j (k) Focus next (previous) window Ditto
Mod4 + Left (Right) Switch to left (right) workspace Ditto
Mod4 + 1-9 Switch to workspace 1-9 Ditto
Mod4 + Shift + 1-9 Move focused window to workspace 1-9 Ditto
 
Layouts Function Comment
Mod4 + Space Switch to next layout Ditto
Mod4 + Shift + Space Switch to previous layout Ditto
 
Multiple screens Function Comment
Mod4 + Ctrl + j (k) Focus next (previous) screen Really handy in a multi-monitor setup
Mod4 + o Send window to next screen Ditto

Multiple screens

In Awesome, by the default the second monitor acts as an independent screen with its own set of workspaces (tags). So with two monitors, you effectively get 18 independent workspaces. This is interesting because you can switch workspaces independently in each monitor, which is probably not the behaviour most people would expect. In my case, this feature is actually very desirable, but other people might find this a bit disconcerting.

Customising

I never cared very much about the looks of the Linux desktop, so I’m not really into customizing Awesome. But sometimes it is necessary to adjust a few things.

Awesome WM can be customised by modifying a Lua script named rc.lua that is read at startup. The file is expected to be located at one of the following directories, in this order:

  • $XDG_CONFIG_HOME/awesome/rc.lua
  • $HOME/.config/awesome/rc.lua
  • XDG_CONFIG_DIRS/awesome/rc.lua

In my system, I could find an example rc.lua in this location:

/usr/share/awesome/lib/shifty/example.rc.lua

Getting the multimedia keys to work

I’m used to changing volume using the multimedia keys of my keyboard. There is no default configuration in Awesome to do this so it is necessary to add a bit code in Awesome’s rc.lua script to make it work. The following is an example on how to bind the multimedia keys to do this type of things:

awful.key({}, "XF86AudioRaiseVolume", function () awful.util.spawn("pactl -- set-sink-volume 1 +10%") end),
awful.key({}, "XF86AudioLowerVolume", function () awful.util.spawn("pactl -- set-sink-volume 1 -10%") end),
awful.key({}, "XF86AudioMute", function () awful.util.spawn("/home/joni/work/tools/bin/pa-vol.sh mute") end),
awful.key({}, "XF86Mail", function () awful.util.spawn("thunderbird") end),
awful.key({}, "XF86HomePage", function () awful.util.spawn("nautilus /home/joni") end),
awful.key({}, "XF86Messenger", function () awful.util.spawn("skype") end),
awful.key({}, "XF86Document", function () awful.util.spawn("libreoffice") end),
awful.key({}, "XF86Favorites", function () awful.util.spawn("firefox") end),
  • Increasing/decreasing the volume is done with Pulseaudio’s pactl command line utility, that allows the control of a running Pulseaudio server.
  • Muting with Pulseaudio is a bit more complicated, but I found a handy script that makes use of the same ~pactl~ utility in combination with padump to achieve the effect of muting and unmuting a specific Pulseaudio sink from the command line. Just needed to make sure that the script would use the right Pulseaduio sink for my system. pacmd list-sinks is one tool that can be used to list Pulseaudio sinks available in a system.
  • I dont’ use other keys like play, stop, next or previous, but other people bind them to control MPD as a backend player.

Start up programs

Finally, there are those programs that you need to start every time you log in your system. So I decided to add those to the Awesome’s config to auto-start them on every session.

awful.util.spawn_with_shell("/usr/bin/radiotray")
awful.util.spawn_with_shell("/usr/bin/hp-systray")
awful.util.spawn_with_shell("/usr/bin/quicksynergy")
awful.util.spawn_with_shell("/home/joni/bin/emacsorg")
awful.util.spawn_with_shell("/home/joni/bin/emacstiz")
awful.util.spawn(terminal)
awful.util.spawn(terminal)
awful.util.spawn("/usr/bin/nautilus")
awful.util.spawn("/usr/bin/firefox")

Other tiling window managers

Currently Awesome is ticking all the boxes for me but I’ve also heard good things about xmonad. Some people have blogged comparisons between these two, but so far my impression is that that there is no clear winner, so this might be an interesting test to do in the future.