Configuring Awesome with Gnome on Ubuntu

The default installation of Awesome for Ubuntu 16.04 (via sudo apt-get install awesome) will create a new X session from which you can run the window manager as a stand-alone. You can then select the entry "awesome" rather than "Unity" at login time. This is fine to get started, but you will find that a number of features coming up with GNOME are then missing:

  • GTK+ theme and configuration (font sizes, etc.) are not applied. This is visible when you run applications like Firefox or Thunderbird.
  • Without the GNOME Keyring, you will have to either type your password every time or run your SSH/GPG agents separately in each terminal.
  • Awesome's wallpaper overrides the GNOME/Unity one, with the latter only showing up when you run e.g. nautilus.

You can avoid this by loading both Awesome and a GNOME Session (without GNOME's window manager and panels) in parallel. Instructions can be found on the page Quickly Setting up Awesome with Gnome of the official Awesome wiki, however it is a bit crowded now, so let me summarize below the steps that work for Ubuntu 14.04 and 16.04.

Configuration files for Awesome

You will need to create three system-wide files. First, /usr/share/xsessions/awesome-gnome.desktop:

[Desktop Entry]
Name=Awesome GNOME
Comment=Dynamic window manager
Exec=gnome-session --session=awesome
TryExec=awesome
Type=Application
X-LightDM-DesktopName=Awesome GNOME
X-Ubuntu-Gettext-Domain=gnome-session-3.0

Second, /usr/share/gnome-session/sessions/awesome.session:

[GNOME Session]
Name=Awesome session
RequiredComponents=awesome;gnome-settings-daemon;
DesktopName=Awesome

Finally, /usr/share/applications/awesome.desktop:

[Desktop Entry]
Version=1.0
Type=Application
Name=Awesome
Comment=The awesome launcher!
TryExec=awesome
Exec=awesome

The second file describes the components that GNOME Session should load to start up the session (we told it the name of the file via the option --session=awesome). Note that gnome-settings-daemon is not installed by default on Ubuntu, so you will also have to run sudo apt-get install gnome-settings-daemon.

GNOME session configuration

At this point, GNOME Session will be started along with Awesome, but it will not load all of its components at startup. These components are described by the files /etc/xdg/autostart/*.desktop, but some of them contain the OnlyShowIn parameter:

OnlyShowIn=GNOME;Unity;

When this parameter is set, the behavior of GNOME Session is to load the component only for GNOME or Unity. As we will be running Awesome, we need to update it to:

OnlyShowIn=GNOME;Unity;Awesome;

Go to /etc/xdg/autostart/, open the file gnome-settings-daemon.desktop and apply this modification. Then, open the .desktop files for the other services that you which to run at startup and apply the same modification. In my case, I ended up editting:

  • gnome-keyring-*.desktop for the session-wide password keyring
  • gnome-screensaver.desktop for the screensaver
  • gnome-settings-daemon.desktop (this one needs to be edited)
  • nautilus-autostart.desktop to load the GNOME wallpaper at startup

Finally, you will notice that the session does not close when you quit Awesome: GNOME Session keeps running, even if there is no window manager left. To quit it properly, one needs to run gnome-session-quit. The awesome wiki proposes a hook of the quit function to remediate this. First, go to your rc.lua configuration file. It should be located in ~/.config/awesome/rc.lua. If you don't have it yet, copy it from the default configuration by:

mkdir -p ~/.config/awesome
cp /etc/xdg/awesome/rc.lua ~/.config/awesome/

Then, add the following at the beginning of the file:

-- Override awesome.quit when we're using GNOME
_awesome_quit = awesome.quit
awesome.quit = function()
    if os.getenv("DESKTOP_SESSION") == "awesome-gnome" then
       os.execute("/usr/bin/gnome-session-quit") -- for Ubuntu 14.04
       os.execute("pkill -9 gnome-session") -- I use this on Ubuntu 16.04
    else
    _awesome_quit()
    end
end

And voilà, you should now have Awesome and GNOME Session living in bonne entente ;-)

Discussion

Feel free to post a comment by e-mail using the form below. Your e-mail address will not be disclosed.

📝 You can use Markdown with $\LaTeX$ formulas in your comment.

By clicking the button below, you agree to the publication of your comment on this page.

Opens your e-mail client.