Make yourself a swank "Show Desktop" applet for Plank

If you don't have the stock MATE panel(s) visible all the time, and prefer a clickable launcher over using CTRL-ALT-D to show the desktop, this walk through will get you a neat little "Show Desktop" icon on your Plank dock. This script uses wmctrl, which is installed by default on Ubuntu MATE 14.04.

First, I grabbed the latest version of Plank from the stable PPA. See HERE for directions if you don't know how. Then start it up.

Create a file called show_desktop and put it somewhere. I put mine in my personal ~/bin folder, inside my home directory.

Open the newly created show_desktop file with Pluma and copy and paste the following:

#!/bin/sh
if wmctrl -m | grep "mode: ON"; then
exec wmctrl -k off
else
exec wmctrl -k on
fi

Set the file to be executable.

Next, I used the MATE Main Menu editor to create a launcher by creating a menu entry for my new "Show Desktop" script. I have the Moka icon pack installed and I told it to use one of the Moka icons as the new launcher icon (in my case this was /usr/share/icons/Moka/48x48/places/user-desktop.png). Pick what floats your boat.

Save your new launcher. The launcher will actually work to clear the desktop from the MATE menu, but the act of opening the menu the second time apparently sets wmctrl's mode: OFF switch, so the script can't place everything back on the desktop. It will work fine from Plank though.

Now lets get our new script into Plank. When you saved your menu entry it created a .desktop file in your ~./local/share/applications directory. Mine enumerates as /home/electragician/.local/share/applications/mozo-made.desktop

Next go to ~/.config/plank/dock1/launchers and create a new file called show_desktop.dockitem and save the file. When you save it, Plank will automatically add the following lines to the file:

#This file auto-generated by Plank.
#2015-02-15T19:09:43+0000

[PlankItemsDockItemPreferences]
#The uri for this item.
Launcher=

Open the show_desktop.dockitem file with Pluma and change the launcher line to read

Launcher=file:/home/YOURUSERNAMEHERE/.local/share/applications/mozo-made.desktop

Now you should have a swank "Show Desktop" item on your Plank. One click minimizes all items, a 2nd consecutive click brings them all back up... or yeah, you can CTRL-ALT-D ... but where's the fun in that?

5 Likes