Monday, October 26, 2015

How To Disable GTK3 Client-Side Decorations (Header Bars)

Starting with GNOME 3.10, some GNOME applications have switched to "header bars" or "client-side decorations". These CSD (client-side decorations) don't work properly in some desktop environments / shells - for instance, in Ubuntu 14.04, Unity doesn't support CSD and because of this, some applications look broken. Luckily, there is now a relatively easy way (unofficial) of disabling client-side decorations. Read on!

In Ubuntu, Nautilus and a few other GNOME apps are patched so they don't use client-side decorations under Unity. However, not all applications were fixed - here are a few examples:

GNOME Clocks

Latest gThumb 3.3.2 (gThumb from the Ubuntu repositories was downgraded when the Ubuntu devs noticed it's using CSD)


GNOME Maps

PCMan, one of the LXDE founders, has created gtk3-nocsd, a small module which can be used to disable the GTK+3 client-side decorations. gtk3-nocsd can achieves this by letting GTK think there's no compositor available, in which case the CSD fail to start.

Update: gtk3-nocsd works with GTK3 older than version 3.16.1 or newer than version 3.17.3. That means it's compatible with Ubuntu 14.04 and 15.04 but not with the latest Ubuntu 15.10.

Here are the same 3 applications as above, with gtk3-nocsd (so with disabled client-side decorations), under Ubuntu 14.04 LTS:




There are a couple of issues though. The first one is that this solution seems to work with most, but not all CSD applications - in my test, GNOME Weather continued to use client-side decorations even after using gtk3-nocsd. And the second issue is that the CSD close button isn't removed when the client-side decorations are disabled. These issues have been fixed in the latest gtk3-nocsd version.

Update: Here's gThumb and GNOME Weather using the latest gtk3-nocsd under Unity (as you'll notice, there's no CSD close button any more, like in the screenshots above):




Install gtk3-nocsd


Ubuntu 14.04 or 15.04 users can install gtk3-nocsd by using the main failsdownloads PPA. To add the PPA and install gtk3-nocsd, use the following commands:
sudo add-apt-repository ppa:nilarimogard/failsdownloads
sudo apt-get update
sudo apt-get install gtk3-nocsd

Or, if you don't want to add the PPA, download the gtk3-nocsd deb from HERE.

Other Linux distributions: grab the gtk3-nocsd code from GitHub, make sure pkg-config and gtk+3-dev are installed and compile it using "make".

Simply installing gtk3-nocsd won't disable the GTK3 client-side decorations. See the example below for how to use it.


Disable GTK3 client-side decorations using gtk3-nocsd (example)


To be able to use gtk3-nocsd, you need to preload the gtk3-nocsd.so file (which is installed under /usr/lib/gtk3-nocsd/ if you've used the Ubuntu PPA mentioned above) using LD_PRELOAD.

Update: for the latest version, the file is now called "libgtk3-nocsd.so.0" however, the PPA package continues to use the old filename (gtk3-nocsd.so) for compatibility purposes.

You can disable GTK3 client side decorations in two ways: either loading it in your ~/.bashrc or ~/.profile, which means that gtk3-nocsd will be used globally (but for your user only), without having to modify anything else, or you can use it for specific applications only.

A. To use gtk3-nocsd globally (for all applications but for your user only), open ~/.profile with a text editor - I'll use Gedit below:
gedit ~/.profile
And at the end of the file, paste this:
export GTK_CSD=0
export LD_PRELOAD=/usr/lib/gtk3-nocsd/gtk3-nocsd.so

Then save the file, restart the session (log out) and that's it!


B. To use gtk3-nocsd with specific applications, you'll need to open the application .desktop file with a text editor and add "env LD_PRELOAD=/usr/lib/gtk3-nocsd/gtk3-nocsd.so" (without the quotes) to the Exec line, just after "=".

Here's an example: to disable the client-side decorations for gThumb 3.3.2, open its desktop file as root with a text editor (I'll use Gedit below):
gksu gedit /usr/share/applications/gthumb.desktop

And in this file, search for the line that starts with "Exec=" and right after "=" and before "gthumb", add the following (without removing anything!):
env LD_PRELOAD=/usr/lib/gtk3-nocsd/gtk3-nocsd.so

After editing gthumb.desktop, the "Exec=" line should look like this:
Exec=env LD_PRELOAD=/usr/lib/gtk3-nocsd/gtk3-nocsd.so gthumb %U

In the same way you can disable client-side decorations for any application you want: GNOME Clocks, GNOME Maps, etc.

No comments:

Post a Comment