Click to change color scheme

Notes on codes, projects and everything

Quick Hack: Terminal Appearing from Right

It is useful to have the terminal around whenever I code. However, while real screen estate is finite, having a terminal further limiting the amount of information that can be displayed at the same time. The problem with the terminal is that I don’t really need it all the time, so I usually find it buried under a group of windows.

Then I decided to find a workaround to the problem, firstly I installed Guake.

Everything works fine, but I find it a bit too wide for my liking. I certainly do not need it to be that wide. It would be nice if I can somehow dock it to the right screen-edge (as left edge is being used by unity’s launcher). However, after digging through the preference options, there seem to be no way of doing that.

So to make it work the way I want, I would have to find workarounds for two problems. Firstly how to shrink the width of the terminal, secondly make it somehow ‘docked’ to the right hand side of the screen edge.

A quick search at google returns this guide, and after much playing with the python script, I modified a couple of things to somehow adjust the terminal to my liking. In short, I modified the main python script to the following state:

    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 = 33
        halignment = ALIGN_RIGHT
 
        # get the rectangle just from the first/default monitor in the
        # future we might create a field to select which monitor you
        # wanna use
        window_rect = screen.get_monitor_geometry(0)
        total_width = window_rect.width
        window_rect.height = window_rect.height * height / 100
        window_rect.width = window_rect.width * width / 100
 
        if width < total_width:
            if halignment == ALIGN_CENTER:
                window_rect.x = (total_width - window_rect.width) / 2
            elif halignment == ALIGN_LEFT:
                window_rect.x = 0
            elif halignment == ALIGN_RIGHT:
                window_rect.x = total_width
        window_rect.y = 0
        return window_rect

In short, I changed the value of width, halignment, and window_rect.x.

So the terminal seems to show up at the place I want it to be. To make it respond to right screen edge, I launched ccsm, and turned off Desktop wall plugin (as I don’t need it and it somehow conflict with the following step). Then in the Commands plugin, I map command 0 to launch guake. The last step is then to bind the right screen edge to command 0.

And there it is, whenever my mouse pointer points to the right screen edge, guake terminal pops up. There are a lot of things I would love to fix though. Firstly being making it to slide out instead of just popping out. Secondly, while I have already set it to disappear after losing focus, I would prefer it to actually disappears whenever my mouse leaves the window (think onmouseout event in like we do in javascript). I am sure there’s a way to actually fix it, but I am happy with what it is for now.

Screenshot from 2013-11-15 23:49:39
Quick screenshot with modded Guake in action.

Should I file a feature request to Guake?

leave your comment

name is required

email is required

have a blog?

This blog uses scripts to assist and automate comment moderation, and the author of this blog post does not hold responsibility in the content of posted comments. Please note that activities such as flaming, ungrounded accusations as well as spamming will not be entertained.

Comments

I use conky for that (:

author
傑夫·翔
date
2014-04-18
time
00:04:55

How did you get the the CPU, filesystem, etc stats on the right side of the terminal? Is that a plugin?

author
Mladen
date
2014-04-17
time
14:56:48