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:
Code:
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...
Code:
# Minimize/restore all windows except the active one
UNDOSCRIPT="$0.data"
# 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\) `
activeWinId="${activeWinIdLine:40}"
# 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"
fi
done
# 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
do
echo "wmctrl -i -a $wnd" >> "$UNDOSCRIPT"
done
echo wmctrl "-i -a $activeWinId" >> "$UNDOSCRIPT" # When restoring, we finally have to restore the original focus
fi