Showing and hiding the desktop in Gnome

Gnome has a button that you can add to a panel to show/hide the
desktop, but there doesn’t seem to be a way to bind that action to a
key. Today I learned about the wmctrl program, which
can perform many window-manager operations, so I put together this
simple script which toggles the “show the desktop” state:

#!/bin/bash
# Toggle the “show the desktop” state.
# Diego Zamboni, Jul 23, 2007

STATE=`wmctrl -m | grep -c ‘showing the desktop.*ON’`

if [[ $STATE -eq 1 ]]; then
OPT=”-k off”
else
OPT=”-k on”
fi

wmctrl $OPT

To map this to Ctrl-F11 (I would have used F11 as in the Mac, but
that’s frequently bound to full-screen mode in applications) using
xbindkeys, I added the
following lines to my $HOME/.xbindkeysrc file:

#Toggle “show desktop”
“toggle_desktop_hide.sh”
m:0x4 + c:95
Control + F11

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s