How to Add ‘Show Desktop’ Shortcut to Left Panel in Ubuntu 20.04 | 22.04

Want to get a shortcut icon to single click minimize all applications to show the desktop? Here’s quick guide shows you how to do it in Ubuntu running on both X and Wayland.

Ubuntu used to have a “Show Desktop” shortcut icon in left dock launcher. It allows you to single click minimize all visual app windows, and click again to restore them. The feature was however removed in recent Ubuntu releases.

If you’re just looking for a way to simulate the function, press Ctrl + Alt + D or Super + D on keyboard will do show desktop feature.

If you intend to add the “Show Desktop” shortcut icon, then this tutorial may help.

This tutorial will work on:

Though title says for Ubuntu 20.04, this tutorial is also tested and works on:

  • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • Ubuntu 23.10
  • Ubuntu 23.04

1. Create a simple show desktop script:

The command line tool wmctrl has a feature to toggle window manager’s “showing the desktop” mode.

1.) Firstly open terminal (Ctrl+Alt+T) and run command to install the tool:

sudo apt install wmctrl

2.) Then create local bin folder if you don’t have it:

mkdir -p ~/.local/bin

3.) Create a file called ‘show-desktop’ and open it via gedit text editor:

gedit ~/.local/bin/show-desktop

For Ubuntu 22.10+, replace gedit with gnome-text-editor.

4.) When the file opens, paste following lines. The script will detect the “showing the desktop” mode status and toggle on or off depending on the value.

#!/bin/bash
status="$(wmctrl -m | grep "showing the desktop" | sed -r 's/(.*)(ON|OFF)/\2/g')"

if [ $status == "ON" ]; then
    wmctrl -k off
else
    wmctrl -k on
fi

5.) After saving the file, make it executable via command:

chmod +x ~/.local/bin/show-desktop

You can now test if the script works by running show-desktop command in terminal. (Log out and back in may required)

2. Create a shortcut for the script:

Now you have to create a shortcut for the script, so you can add it into the left (or bottom) dock launcher.

1.) Firstly open terminal and run command to create a .desktop file and open in gedit text editor:

gedit ~/.local/share/applications/show-desktop.desktop

For Ubuntu 22.10+, replace gedit with gnome-text-editor.

2.) When it opens, paste following lines and save it.

[Desktop Entry]
Type=Application
Name=Show Desktop
Icon=desktop
Exec=/home/USER_NAME/.local/bin/show-desktop
Replace USER_NAME to yours! 

If ~/.local/bin is in the PATH (see whether running show-desktop in terminal work or not), you may replace the full path "/home/USER_NAME/.local/bin/show-desktop" simply with "show-desktop".

NOTE: wrong value of “Exec” may cause the icon not shown in search results.

3. Add the shortcut to the Dock Panel:

Finally, click Activities or Show Applications and search for ‘Show Desktop’ (without quotes), right-click on the icon and select “Add to Favorites” or “Pin to Dash”.

You’re done. Enjoy!

Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.