A simple GUI for Unity-2D Settings (Ubuntu 11.04)

This is a very simple configuration tool I made to save time browsing folders and adding values in Gconf, or writing commands in the terminal to customize certain aspects of the new Unity-2D Desktop.

There’s not much to tweak under the current version of Unity-2D. However, there are certain times -Specially while I’m running Ubuntu on a VM- that I want to set the Launcher to be hidden or vice versa, and Compositing Manager makes it look way better (Near regular Unity) adding window edge shadows, transparency in the Dash and Alt-Tab Switching thumbnail previews.

Download (.deb Installer): Compatible only with 11.04 Natty Narwhal

An updated version for 11.10 oneiric can be found in this post and for 12.04 Precise LTS in this post.

Notes: If you click the compositing manager checkbox, hit “Alt+Tab” to refresh your desktop since by enabled-disabled you get a black screen.
The ‘Always Show’ option for the launcher is tricky to set when it’s hidden (A native bug in Unity-2D caused by the ‘use-strut’ gconf key), you can use “Super” or “Alt+F2″ keyboard shortcuts to bring the launcher back in position.

The code:

#! /usr/bin/python

# 2D-Desktop Settings 1.0-5
# Small desktop configuration tool for Unity-2D (11.04)
#
# Copyright 2011-2012 by Mariano Chavero
#
# Distributed under de GNU/GPL V3
# Visit <http://www.gnu.org/licenses/> for more information.

import gtk, gconf

class Settings(gtk.Window):

    def label(self, text):
        box = gtk.HBox()
        lbl = gtk.Label(text)
        lbl.set_use_markup(True)
        lbl.set_alignment(0, 0.3)
        box.pack_start(lbl, False, False, 25)
        return box

    def Checkbox(self, text, key):
        client = gconf.client_get_default()

        box = gtk.HBox()
        bttn = gtk.CheckButton(text)
        bttn.set_active(client.get_bool(key))
        bttn.connect("toggled", self.on_Checkbox_toggled, client, key)
        box.pack_start(bttn, False, False, 50)
        return box

    def RadioButton(self, text, key, val, group):
        client = gconf.client_get_default()

        box = gtk.HBox()
        bttn = gtk.RadioButton(group, text)
        bttn.set_active(client.get_int(key) is val)
        bttn.connect("toggled", self.on_RadioButton_toggled, client, key, val)
        box.pack_start(bttn, False, False, 50)
        return box

    def on_Checkbox_toggled(self, widget, client, key):
        client.set_bool(key, widget.get_active())

    def on_RadioButton_toggled(self, widget, client, key, val):
        if not widget.get_active(): return
        client.set_int(key, val)

        # A desktop strut value is set, required by the Unity 2D Launcher
        client.set_bool("/desktop/unity-2d/launcher/use_strut", not bool(val))

    def Separator(self):
        return gtk.HSeparator()

        # Loads the system theme icon of your choice :)
    def theme_load(self, icon_name):
        t = gtk.icon_theme_get_default()
        return t.load_icon(icon_name, 48, 0)

    def __init__(self):
        gtk.Window.__init__(self, type=gtk.WINDOW_TOPLEVEL)
        self.set_resizable(False)
        self.set_border_width(10)
        self.set_title("2D-Desktop Settings")
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_icon(self.theme_load("gnome-fs-desktop"))
        self.connect("destroy", lambda q: gtk.main_quit())

        # Creates one group for our existant Radio Buttons
        rbttngroup = gtk.RadioButton(None)

        ### Layout ###
        Container = gtk.VButtonBox()

        Container.add(self.label("<b>Launcher Behaviour</b>"))

        Container.add(self.RadioButton("IntelliHide (Dodge with Windows)",
           "/desktop/unity-2d/launcher/hide_mode", 2, rbttngroup))

        Container.add(self.RadioButton("Auto Hide",
           "/desktop/unity-2d/launcher/hide_mode", 1, rbttngroup))

        Container.add(self.RadioButton("Always Show",
           "/desktop/unity-2d/launcher/hide_mode", 0, rbttngroup))

        Container.add(self.Separator())

        Container.add(self.label("<b>Unity 2D Dash</b>"))

        Container.add(self.Checkbox("Show Dash using the Super Key (Windows Logo)",
           "/desktop/unity-2d/launcher/super_key_enable"))

        Container.add(self.Separator())

        Container.add(self.label("<b>Desktop</b>"))

        Container.add(self.Checkbox("Enable Window Shadows and Transparency",
           "/apps/metacity/general/compositing_manager"))

        Container.add(self.Checkbox("Show Volumes and Devices",
           "/apps/nautilus/desktop/volumes_visible"))

        box = gtk.VBox()
        box.add(Container)
        self.add(box)
        self.show_all()
        gtk.main()
if __name__ == "__main__":
    Settings()

Follow

Get every new post delivered to your Inbox.