I have an application using multiple windows. How can I quickly bring all the windows of that application to the foreground?
When I scroll through the applications with the scroll-wheel it only shows one window. When going to the next window, the last window is brought to the background again.
When I click on the application icon, I get a full-screen overview of all the windows. I have to select each window manually and move my mouse across half the screen several times.
My best solution so far is minimizing all windows (Ctrl+Super+D) and then show the windows of my application using the scroll-wheel.
Is there a better solution?
Best Answer
EDIT -new answer-
The answer(s) below is/are still totally valid, and so the suggested options. Ongoing insight however made me add this option to use the indicator below, which is probably the most elegant solution.
As such, it should probably replace option 5 (using a .desktop file).
Simply choose the application from the list, and all windows of the corresponding application (present on the current viewport) will raise:
How to use
from ppa:
...or manually:
The indicator needs
wmctrl
Copy the indicator into an empty file, save it as
raise_apps.py
Copy the image below, save it exactly named
raise.png
in one and the same directory as the indicator.Then simply run it by the command:
python3 /path/to/raise_apps.py
Add if you want to Startup Applications:
OLD ANSWER:
About the question
With the right tools, it is not very complicated to "just" raise all windows of an application. It is a bit more complicated to make sure only the windows of the current viewport are raised. The real challenge however is to find a convenient way to make the action available to the user.
Below five options to take care of that, to show how it can be done. All options are ready to be used. The last option however is kind of experimental; it works fine but has a few minor cosmetic downsides, as explained in the description of the option. I added it nevertheless as a concept.
Spreading the windows automatically in a non- overlapping way, as suggested in a comment, seems not a practical idea to me; if you work in an (application-wise) grouped window setup, the script would possibly unwantedly rearrange windows.
How to use
For all options you need to:
install
wmctrl
if it is not yet on your system:create, if it does not exist yet, the directory:
(explanation: the directory
~/bin
is in $PATH, so you can run executables by their name)Copy the script, corresponding to the option, paste it into an empty file, save it as
raise_app
(no extension) in~/bin
and make it executableIn the separate options, possible additional steps will be explained.
Option 1: choose the application by entering one or more characters
zenity
window will appearThis will make all windows of the matching application (on the current viewport) come to front.
raise all
gnome-terminal
windows on the current viewport:How to use:
Test-run it by the command:
If all works fine, add it to a shortcut key combination of your choice: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command
The script:
Option 2: cycle through applications and raise their windows with a key combination:
Let's say I have the script below under a key combination Alt+1. I have several windows open of:
The current state:
I press once Alt+1, all
nautilus
windows are raised:I press again Alt+1, all
firefox
windows are raised:I press again Alt+1, all
gnome-terminal
windows are raised again, the cycle starts over:How to use
Add it to a shortcut key combination of your choice: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command
Then cycle through your applications with grouped application windows with your key combination.
The script:
Option 3: press key combination + click on launcher icon -or- application window to raise all windows on the current viewport
This is probably the option that is closest to what is described in the question / comment.
Let's say I have a messy desktop with three
nautilus
windows buried under other windows.To raise all nautilus windows (example shortcut: Alt+1):
Within 3 seconds, either:
click on the application's icon in the launcher
or:
click on one of the application's windows
result:
How to use:
Test-run it by the command:
If all works fine, add it to a shortcut key combination of your choice: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command
Then:
Press your key combination and within 3 seconds, either:
The script
Option 4: a key combination calls an option list, showing the number of windows per application on the current viewport
This one turned out to be more convenient then I assumed:
Pressing the (again example-) key combination Alt+1 calls a
zenity
window, listing all applications and the number of their windows on the current viewport:Simply pressing the ▴ or ▾ arrows will bring you to the right option. Press Enter and all windows of the chosen application are raised.
How to use:
Test-run it by the command:
If all works fine, add it to a shortcut key combination of your choice: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command
The script
Option 5: raise windows of running applications from a launcher icon
This option exists of a launcher icon, with the currently running applications in a quicklist. Choose one, and all windows of the applications will be raised.
The launcher is automatically updated when the list of running applications (on the current viewport) changes. The quicklist shows a different list on other viewports, where windows of other applications are opened (will take 1-2 seconds to adapt).
As mentioned, although fully functional, this option is a meant as a concept. It has a few minor cosmetic downsides as it is. The most important:
Furthermore the setup is slightly more complicated (although explained in detail below):
How to use
Below you will find:
two scripts / an icon / a
.desktop
fileraise_app
in~/bin
Save the icon below (right-click, save as) as
raise.png
Copy the
.desktop
file into an empty file, edit the lineto the real path to the icon (paths with spaces between quotes)
Save it as
raise.desktop
in~/.local/share/applications
Drag the
.desktop
file to the launcher to add itupdate_apps
in~/bin
, make it executable.Add the following command to your startup applications (Dash > Startup Applications > Add):
The first script
The second script
The .desktop file
Brief Explanation
All solutions above use
wmctrl
to create a window list, using thewmctrl -lpG
command. This command produces lines, looking like:These lines include:
xrandr
)The pid is looked up in the output of
ps -u <username>
to get a "user-readable" identification (name) of the application.Thus we can allocate windows to applications. Subsequently we can raise the windows of a given application in a
for
loop with the commandwmctrl -ia
.In option 3
the script starts a 3- second "waiting" loop, using the
xprop -root
command repeatedly to see if there is any change in what is the frontmost window; this will happen if the user either clicks on a launcher icon to raise an application's window, or clicks on a window directly. If so, the while- loop breaks and looks up the "new" frontmost application, and subsequently raises all other windows of that application.