I have monitor and laptop screen and have a problem with the "Show desktop" function.
Laptop screen is showing widget that should stay for all the time. Main monitor is used normally.
Whenever I use keyboard shortcut (windows key + d in my case), all windows will be hidden but I only want to hide all the windows on the specific monitor.
Is this possible?
Question similar to https://superuser.com/questions/200945/how-can-i-make-the-show-desktop-function-only-hide-the-windows-on-a-specific-m, with notable difference that I ask about different OS.
Only minimize windows on one screen
The script below can be used to (only) minimize windows on the left screen or only on the right screen.
The script is run with either
1
or2
as argument, depending on which screen you'd like to minimize the windows.The script
How to use
The script needs both
wmctrl
andxdotool
Copy the script into an empty file, save it as
min_screen.py
To run it:
to minimize windows on the left screen, and
to minimize windows only on the right screen
Notes
Unity
, but unlike workspaces (viewports), handling the screens should not make a difference.tkinter
windows for example). If that is an issue, please mention. Can be solved.Explanation
The script first looks up the right edge of the left screen, by looking up the string with
+0+
in the output ofxrandr
, looking like:The first section,
1680
, is the widht of the left screen. Subsequently, all we have to do is look into the window list (wmctrl -lG
) and see which of the windows is "below" or "above"1680
, and act accordingly, minimizing with the commandxdotool windowminimize <window_id>
(or not).Th "test" finally (
mmiz
):xprop -id <window_id>
is to check if we are dealing with a "normal" window (instead of e.g. your desktop, which is also listed as a window), and if the window is already minimized.See also the comment in the script.
Binding the script to a keyboard shortcut
1. On Lubuntu
To edit global keyboard shortcuts in Lubuntu see Lubuntu minimize all show desktop keyboard shortcut?
In this case: save script from this answer into a file on the computer, make this file executable, open
/.config/openbox/lubuntu-rc.xml
and replaceby
where
/path/to/show_desktop.py
is (of course) the path to the script, and either1
or2
the targeted screen. Make the script executable.Restart computer to reload config.
2. Unity/Gnome
Make the script executable and choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:
...to a shortcut of your choice
Introduction
The script below allows user to click on a display they want, and all windows on that display will be minimized. This script is meant to be bound to a keyboard shortcut, but can run manually if so desired.
Usage is simple:
The program doesn't require any additional packages to be installed. The script has been tested on regular Ubuntu 16.04 LTS and Lubuntu 16.04 LTS. Thanks to @JourneymanGeek for testing it on Fedora 24 with KDE as well !
Obtaining the script source code
The script source code can be obtained by manually copying it here, or by getting it from my github repository. To obtain it via
git
follow these steps:sudo apt-get install git
cd /opt ; sudo git clone https://github.com/SergKolo/sergrep.git
sudo chmod -R +x sergrep
The file will be called minimize_display_windows.py . Make sure when you bind that to a keyboard shortcut to provide full path to the script. For instance, like so:
Source code
Ensure the file you save this code to, has executable permissions.
Demo
A short recording of the script in action can be found on my youtube channel
Side-notes
Originally , I've written another script , but it can only be used in Unity and requires xdotool to be present. For those interested it is posted as gist