Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use Guake at right monitor.

So I added this ppa by sudo add-apt-repository ppa:cberner/guake, and sudo apt-get update.

https://launchpad.net/~cberner/+archive/guake/+index?field.series_filter=raring

Instruction says that I can set monitor_index somehow. But I couldn't find how to configure.

Does someone know about this?

share|improve this question

I use two monitors and wanted Guake to be displayed on the right one (where by default it is displayed on the left one).

What I did was to edit my /usr/bin/guake/ file replacing the get_final_window_rect method with this:

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 = 100
    halignment = self.client.get_int(KEY('/general/window_halignment'))

    # get the rectangle just from the first/default monitor in the
    # future we might create a field to select which monitor you
    # wanna use
    monitor = 1 # use the right most monitor
    window_rect = screen.get_monitor_geometry(monitor)
    # see if we don't have another screen, and if so, use the first one
    if window_rect.width == 0:
        monitor = 0
        window_rect = screen.get_monitor_geometry(monitor)
    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
            if monitor == 1:
                    right_window_rect = screen.get_monitor_geometry(0)
                    window_rect.x += right_window_rect.width
        elif halignment == ALIGN_LEFT:
            window_rect.x = 0
        elif halignment == ALIGN_RIGHT:
            window_rect.x = total_width - window_rect.width
    window_rect.y = 0
    return window_rect

Basically, it uses 1 as the monitor index and later on, adds the right screen width to the start point display of the guake window

hope this helps!

share|improve this answer
    
How did you open that file in order to edit it? I did it via xdg-open $file but it opens as read-only. – kevin Nov 25 '14 at 16:58
    
Any text editor will do, use sudo at the beginning of the command to have admin privileges – wilfo Nov 25 '14 at 17:02
    
Thanks, it worked fine! – kevin Nov 25 '14 at 17:10
    
Oddly, this alternates between left and right every time I open it when I set 'Launcher placement' for the left monitor only. Setting it to the right one gets it to work every time. – rmobis May 19 '15 at 17:32
2  
It's true. Your comment made my install the latest version of Guake (from this ppa: https://launchpad.net/~webupd8team/+archive/ubuntu/unstable and it seems that they've made it so now that you can choose between the terminal appearing on the screen the mouse is at, or locking it to a specific screen, which I guess is a good enough solution in my opinion – wilfo May 20 '15 at 11:28

The solution is very simple, as you want to align your Guake screen to your right hand side monitor so in starting position (x, y) of screen, y co-ordinate is going to be same i.e. it will start from 0 but x coordinate will change and it should be equal to width of you left side monitor. To be able to do this you need to do 2 things.

I. Change monitor number to 1, as suggested above. In line

window_rect = screen.get_monitor_geometry(0)

Replace 0 by 1.

II. Add first screen width in x position of starting co-ordinate. to do this.

Replace

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.width
window_rect.y = 0
return window_rect

By

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.width
window_rect.y = 0
return window_rect

Once you do these changes and restart guake (Quit and start again), You should get the desired alignment of Guake screen.

Hope this helps :)

share|improve this answer

The solution by wilfo doesn't work to me. In my case i solved on Linux Mint with the following code:

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 = 100
    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

I take it from here, but i changed 80 to 100.

share|improve this answer

I haven't tested this but I think you can just edit /usr/bin/guake since it is a python script.

Find

window_rect = screen.get_monitor_geometry(0) #line 824 on my machine

and change the 0 to the index of the monitor you want guake to display in.

share|improve this answer
    
I edited the line 0 to 1 in /usr/lib/guake/guake.py. And restart guake, but nothing changes. – ironsand Apr 8 '14 at 23:45

I also made this a question: guake at right side monitor in dual display environment - Ubuntu 15.10(Wily Werewolf))

In Ubuntu 15.10 guake has changed a little bit. To change your terminal to the right monitor you have to edit:

sudo vim /usr/lib/python2.7/dist-packages/guake/guake_app.py

then change in line 831:

window_rect = screen.get_monitor_geometry(monitor)

by:

window_rect = screen.get_monitor_geometry(1)

kill and restart guake

Anyone knows a way to do this less hacky?

share|improve this answer

As lalit said, the best way I found to do this on ubuntu 14.04LTS was changing

window_rect = screen.get_monitor_geometry(0)

to

window_rect = screen.get_monitor_geometry(0)

but changing

    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.width
window_rect.y = 0
return window_rect

to

 if width < total_width:
     if halignment == ALIGN_CENTER:
         window_rect.x += total_width + (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.width
window_rect.y = 0
return window_rect

The only difference its in the first "if", without adding "total_width" to "window_rect.x" guake appears in the middle of my left monitor.

P.S: Sorry Lalit but I cannot add a comment to your post since I have no points yet =(

share|improve this answer

Just to add to smartmouse and wilfo's answers, once you make the change to /usr/bin/guake you then have to to a hard restart. Logging out of the guake session does not end the Guake process.

Open system monitor and kill the guake application process then restart

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.