Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Desktop
User Name
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.


  Search this Thread
Old 07-03-2009, 12:32 PM   #1
Registered: Dec 2005
Distribution: debian (testing/unstable)
Posts: 57

Rep: Reputation: 17
Post minimize all windows EXCEPT the active one (toggle)

Most Window Managers come with an "Show Desktop" feature, that will toggle all non-minimized (-iconized) Windows to minimized and back.
Futhermore, in KDE3 we had the possibility to script it by:

dcop kicker kicker toggleShowDesktop
In KDE4, this obviously does not work anymore, we are left off with a button that eats up valuable space in the task bar.

M$ is ostentatiously about a new feature in W****** 7 which does the same but leaves the active window untouched. For this, you have to "shake" the windows (which is quite tedious in comparison to some hotkey).

This really could be handy e.g. if you are working in a file manager (or browser) and want temporarily access to your desktop to place a link there.
And the most comfortable way should be a plain shell script that can be assigned to a hotkey at discretion.

Well, first I thought this would be an easy job to to. The idea is clear and presented below, but far from working as expected. As it took more than an hour of searching and trying to find a method how to determine the active window, I leave the 'pseudocode ' here - maybe we work it out collaboratively...

 # Minimize/restore all windows except the active one
 # Determine whether we have to minimize or to restore in this run
 if [ -f "$UNDOSCRIPT" ]
  then # restore previously minimized windows and forget the past
       sh "$UNDOSCRIPT"
       rm "$UNDOSCRIPT"
  else # minimize all but active window
       # Determine the active window
        activeWinIdLine=`xprop -root | grep _NET_ACTIVE_WINDOW\(WINDOW\) `
       # Store a list of currently existing windows by IDs
        allWindowsIds=`wmctrl -l | cut -f1 --delimiter=" " `
       for wnd in $allWindowsIds
       do  # check whether this window is minimized yet
 	 xwininfo -id $wnd -all | grep -q "Map State: IsViewable"
 	 if [ $? -lt 1 ]
 	    then # build a list of currently viewable windows that we have to minimize
 	       unminimizedWindIDs="$unminimizedWindIDs $wnd"
       # Minimize all windows except the active one
        xwit -iconify -all
        wmctrl -i -a $activeWinId
       # Now we minimize normal and maximized windows and create a script to undo all that the next run
       echo > $UNDOSCRIPT # To be sure it is empty first
       for wnd in $unminimizedWindIDs
 	   echo "wmctrl -i -a $wnd" >> "$UNDOSCRIPT"
       echo wmctrl "-i -a $activeWinId" >> "$UNDOSCRIPT" # When restoring, we finally have to restore the original focus

Last edited by devdol; 07-03-2009 at 12:36 PM. Reason: more details
Old 07-03-2009, 02:12 PM   #2
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960
"xdotool getactivewindow" will give you the window id of the currently-focused window.

Last edited by David the H.; 07-03-2009 at 02:14 PM.
Old 07-03-2009, 04:39 PM   #3
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 386Reputation: 386Reputation: 386Reputation: 386
I guess you want this for kde, or are you open to alternative -scriptable- window managers?

In fvwm I'd do

All (!Focused) Iconify on

Last edited by i92guboj; 07-03-2009 at 04:41 PM.


desktop, manage, script, toggle

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to minimize all windows? mfeat Red Hat 15 11-11-2016 02:17 PM
Windows minimize to ---nowhere? DougC Fedora 7 10-24-2015 03:52 AM
Minimize all windows tranh2 Linux - Newbie 2 08-28-2006 06:59 PM
Toggle between Linux & windows ppkamma Linux - Newbie 4 05-31-2006 02:23 PM
Minimize active window in KDE? Ander Linux - General 3 05-05-2006 01:56 AM > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration