Toolbox
  • Printable version
 
Toolbox
LANGUAGES
Language
Personal tools
Wikipedia Affiliate Button
 

Guake on the right screen

From BrightByte

Jump to: navigation, search

Guake is a nice pull-down terminal emulator for GNOME. When trying it out, it had one major flaw: it gets confused when using multiple monitors. So I hacked it.

The problem is that guake is hard coded to use your left most screen. Even if you change that, it will calculate it's position relative to the (0,0) origin on the left most screen. But my left screen is smaller than my right screen, and my right screen is my primary. So, quacke comes up with the correct size in the wrong place, completely out of shape and unusable because the top part of the terminal is off-screen.

So, here's a fix. Note that it hard-codes some idiosyncratic customization, such as an 80% width. Guake could really use configuration for this.

Anyway. Edit /usr/lib/guake/guake.py or wherever guake.py is located on your system. Edit the method get_final_window_rect to be the following:

    def get_final_window_rect(self):
        """Gets the final size of the main window of guake. The height
        is the window_height property, width is window_width and the
        horizontal alignment is given by window_alignment.
        """
        screen = self.window.get_screen()
        height = self.client.get_int(KEY('/general/window_height'))
        width = 80
        halignment = self.client.get_int(KEY('/general/window_halignment'))
 
        # future we might create a field to select which monitor you
        # wanna use
        #monitor = 0 # use the left most monitor
        monitor = screen.get_n_monitors() - 1 # use the right most monitor
 
        monitor_rect = screen.get_monitor_geometry(monitor)
        window_rect = monitor_rect.copy()
        window_rect.height = window_rect.height * height / 100
        window_rect.width = window_rect.width * width / 100
 
        if width < monitor_rect.width:
            if halignment == ALIGN_CENTER:
                window_rect.x = monitor_rect.x + (monitor_rect.width - window_rect.width) / 2
            elif halignment == ALIGN_LEFT:
                window_rect.x = monitor_rect.x
            elif halignment == ALIGN_RIGHT:
                window_rect.x = monitor_rect.x + monitor_rect.width - window_rect.width
 
        window_rect.y = monitor_rect.y
        return window_rect

Restart guake, and that's it!