BrT

Musings about technology and other neat stuff

BrT random header image

Showing and hiding the desktop in Gnome

July 23rd, 2007 · No Comments

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:0×4 + c:95
Control + F11

Tags: ·