Ubuntu / Linux news and application reviews.

docky show desktop

Update: Docky now has it's own "Show Desktop" applet, but Docky and Gnome DO are separate applications for a while and a lot of people are still using the old Docky integrated into Gnome DO, so this should still be useful.

I know a lot of you are using Gnome Do for quite some time, but I've only recently switched to it. One of the most annoying things when running it in Docky mode (Dock bar) is that it doesn't have to many applets, and I can live with that but now without a "Show Desktop" shortcut.

Yes, you can use a keyboard shortcut for showing the desktop, but I wanted this in Gnome Do / Docky and managed to create an applet (actually a script) to use in Docky.

The main challenge was to find a way to show / hide the windows from within a terminal. Then I found wmctrl, a tool which can hide / restore your windows from the command line.

The following instructions are for Ubuntu / Gnome, but should work for other Linux distributions / desktop environments too.

1. Install wmctrl:
sudo apt-get install wmctrl

2. Create an empty file and call it whatever you want. I have a Scripts folder in my Home directory where I keep all these scripts, so you can do the same. Let's say we call the script "show_desktop.sh". Paste the following code inside this file:
if wmctrl -m | grep "mode: ON"; then
exec wmctrl -k off
exec wmctrl -k on

And make it executable. To do this, open a terminal and:
chmod +x /path/to/show_desktop.sh

Replace /path/to with the path to where you created the script.

3. Now right click on your Gnome panel and select "Add to panel" and select a new "Custom application launcher". Choose whatever icon you want for it, name it "Show Desktop" (this name will be displayed when hovering the icon in Docky) and in the command field, enter the full path to the show_desktop.sh file you just created.

You can play with this new custom launcher to see if it's working.

4. We're basically done, all you have to do is drag and drop this launcher to Docky.