Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When opening programs like GIMP, I find having background windows open distracting because GIMP has three separate windows associated with it.

It's a burden to have to go to every other non-Gimp window manually to minimize it. What I need is a keyboard shortcut in Ubuntu that matches Windows' Super + Home shortcut. One that minimizes all windows except the active one.

Is it possible to achieve this behavior in Ubuntu?

share|improve this question
    
Interesting idea! Have a look at the 1st answer here for pointers: askubuntu.com/questions/13709/… That post is about adding a function to minimize all. From looking at it adding a line 'maximize previous current active' or changing it to 'minimize except current active one' after it would do the trick(?) –  Rinzwind May 4 '11 at 14:08
    
any chance the developers will add a "Minimize All But The Active Window" option in the Keyboard Shortcut menu in future Ubuntu versions? This way this bind is "ready and waiting" to be configured when users install Ubuntu? –  Chad May 4 '11 at 14:31

1 Answer 1

It is possible to achieve this with a python script. The script requires python-wnck and python-gtk to be installed in order to work, although I think these are installed by default anyway.

Copy and paste this into a text editor and save in a sensible place (eg. as minimise.py in your home folder):

#!/usr/bin/env python
import wnck
import gtk

screen = wnck.screen_get_default()

while gtk.events_pending():
    gtk.main_iteration()

windows = screen.get_windows()
active = screen.get_active_window()

for w in windows:
    if not w == active:
        w.minimize()

You can then set up the keyboard shortcut by opening Keyboard Shortcuts.

Keyboard Shortcuts in Dash

Click on Add to create a new shortcut.

Keyboard Shortcuts window

Use the command bash -c 'python ~/minimise.py' (this is assuming you saved it as minimise.py in your home folder).

create shortcut

You can then assign your preferred keyboard combination to this action.

The script will minimise all non-active windows. I don't think this is very useful for your use case because you will want to have all of the Gimp windows open. You can use a slightly different script to minimise all windows that aren't from the current application instead:

#!/usr/bin/env python
import wnck
import gtk

screen = wnck.screen_get_default()

while gtk.events_pending():
    gtk.main_iteration()

windows = screen.get_windows()
active_app = screen.get_active_window().get_application()

for w in windows:
    if not w.get_application() == active_app:
        w.minimize()
share|improve this answer
1  
+1! This is why I love Linux! Excellent. @chad: if the multiple windows of gimp is a problem there seems to be a way to have gimp act as 1 window. Oops: it seems to be the default from 2.6 (go figure; I haven't used gimp for a long time). –  Rinzwind May 4 '11 at 17:50
    
This is why I love Python - it has a module for everything! –  dv3500ea May 4 '11 at 17:51

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.