5

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.

4 Answers 4

3

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.

3
  • A good tool, but it would be a lot nicer if there was something like the 'Quit' option in Unity's context menu Commented Feb 28, 2013 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
    Commented Feb 28, 2013 at 18:05
  • For example killall evince closes all open pdf windows. Commented Nov 25, 2015 at 14:23
2

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.

4
  • 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. Commented Mar 1, 2013 at 14:08
  • did you check both options? Commented Mar 1, 2013 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."). Commented Mar 2, 2013 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 Commented Mar 2, 2013 at 7:10
2

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".

4
  • The question and title specifically mentions GNOME shell.
    – iBelieve
    Commented Feb 28, 2013 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. Commented Feb 28, 2013 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 Commented Feb 28, 2013 at 19:53
  • See an alternative approach in my 2nd answer, specifically aimed at the GNOME Shell (as opposed to Unity)... Commented Feb 28, 2013 at 20:04
0

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.

3
  • Does xkill not actually the same?
    – Thomas15v
    Commented Feb 28, 2013 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. Commented Feb 28, 2013 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
    Commented Feb 28, 2013 at 18:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .