Saturday, June 11, 2011

Show Desktop Applet for Unity Launcher

A 'Show Desktop' applet wasn't included in Ubuntu Natty. However, there may be one present in Ubuntu Oneiric by default. Still, you can create a custom one for Natty as well.

1. Firstly, we need to install a control program for window management:

sudo apt-get install wmctrl

2. Create a script for 'wmctrl':

gksudo gedit /usr/local/bin/showdesktop

3. Paste this code into the newly created file:

if wmctrl -m | grep "mode: ON"; then
exec wmctrl -k off
exec wmctrl -k on

Save and close the file.

4. Make the file executable:

sudo chmod +x /usr/local/bin/showdesktop

5. Create a .desktop file for the new applet, copy & paste the content all at once:

echo "[Desktop Entry]
Name=Show Desktop
StartupNotify=false" | sudo tee ~/.local/share/applications/showdesktop.desktop

6. Open your /home directory. Press Ctrl + H to see the hidden files and navigate to .local/share/applications. Drag and drop the "showdesktop.desktop" file you see there to the Unity Launcher and you are done.

When you click the icon, it starts blinking and might not respond to clicks for the next 10 sec or so unless the blinking stops. In that duration, you can use middle-click and force it to respond immediately.

Related Posts:

Accessibility , Launcher , Unity