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.

As the title says, Is there a shortcut to close all windows of the same application in gnome shell, or an extension to do this?

Thanks.

share|improve this question

4 Answers 4

up vote 2 down vote accepted

You may wanna test-ride the window-options-gnome-shell-extension from bitbucket.org, last updated Nov. 2012 (thus appears to be actively maintained).

... added option to close the current window (as opposed to the 'Quit' button that closes the entire application (i.e. all its windows)).

Enjoy!

ps:

Alternatively, you may (also) want to look into this SOLVED thread, which seems to offer yet another solution.


EDIT: "Quit from dash" is now an extension on the gnome extensions website.

share|improve this answer
    
This is quite useful, but I use a task bar extension that hides the original window title bar, thus I cannot use it. Thanks for your help. –  khalafnt Mar 1 '13 at 14:08
    
did you check both options? –  nutty about natty Mar 1 '13 at 14:40
    
The extension link in the second option redirects me to a broken link; ("The file you are looking for has been deleted or moved."). –  khalafnt Mar 2 '13 at 7:02
1  
I found the extension in the second link in the gnome extensions website. Here's the link extensions.gnome.org/extension/559/quit-from-dash –  khalafnt Mar 2 '13 at 7:10

You can do the following command in terminal.

killall <application>

or press super key (windows/apple/ubuntu key) and type xkill. And click on the application you want to kill.

share|improve this answer
    
A good tool, but it would be a lot nicer if there was something like the 'Quit' option in Unity's context menu –  khalafnt Feb 28 '13 at 18:00
    
Do you mean like a shortcut? yeah than you will need to program a script i think :/. If you wan't to see all the commands available on unity just hold super ;). –  Thomas15v Feb 28 '13 at 18:05

Assuming you're using UNITY and its LAUNCHER, you can do so ("Close all windows of the same application") by selecting the target application in LAUNCHER and then using the right arrow button to "Quit".

share|improve this answer
    
The question and title specifically mentions GNOME shell. –  iBelieve Feb 28 '13 at 17:57
    
I know. I'm trying to be helpful rather than punctilious; the question asks for a shortcut, and the method I described is very short-cut for me in my set-up. But attaching a shortcut to a command as in Thomas Vanmellaerts answer is fine, too, of course! That's a matter of taste. Further, I'd generally prefer to gently end-close my applications than brutally kill ("execute") 'em. –  nutty about natty Feb 28 '13 at 18:02
    
@iBelieve Could be there is no option in GNOME Shell to close .. like in Launcher, at least not by default: live.gnome.org/GnomeShell/CheatSheet –  nutty about natty Feb 28 '13 at 19:53
    
See an alternative approach in my 2nd answer, specifically aimed at the GNOME Shell (as opposed to Unity)... –  nutty about natty Feb 28 '13 at 20:04

Here is a script which will close all windows of a certain application when you click on one of its windows (using killall):

#! /usr/bin/env python

import sys,os, subprocess

# Function based on code from Apport
def get_window_pid():
    xprop = subprocess.Popen(['xprop', '_NET_WM_PID'],
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (out, err) = xprop.communicate()
    if xprop.returncode == 0:
        try:
            return int(out.split()[-1])
        except ValueError:
            error_message(_('Cannot identify package'),
                    _('xprop failed to determine process ID of the window') + '\n\n' + err)
            return -1
    else:
        error_message(_('Cannot identify package'),
                _('xprop failed to determine process ID of the window') + '\n\n' + err)
        return -1

def get_window_exe():
    pid = get_window_pid()

    if pid == -1:
        return ''

    return os.path.realpath('/proc/' + str(pid) + '/exe')

def close_all():
    app = get_window_exe()
    os.system('killall ' + app)

if __name__=='__main__':
    close_all()

Save this to a file (such as closeall), and make sure it is in the system path and is executable.

Then you can run it at any time by pressing Alt+F2 and typing closeall.

share|improve this answer
    
Does xkill not actually the same? –  Thomas15v Feb 28 '13 at 18:25
    
Wow, nice effort. This is like xkill suggested by Thomas Vanmellaerts. But I am looking for something like the 'Quit' option in unity launcher, thanks for your help. –  khalafnt Feb 28 '13 at 18:27
    
@ThomasVanmellaerts This closes all the windows of a particular application (not just one). I don't think xkill can do that, though I'm not sure what the -all option does. –  iBelieve Feb 28 '13 at 18:30

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.