I am migrating from Unity to GNOME. One item I am missing is a "Show desktop" button (aka "minimise all windows") in the dash. How can I add this functionality to the GNOME dash (or Ubuntu dock in Ubuntu 17.10 and later), even if it means making a custom .desktop file?

(I know that I can use the Ctrl + Super + D keyboard shortcut to show the desktop and that I can install an extension to add a "Show desktop" button to the top bar, but I specifically want a button in the dash.)


3 Answers 3


I found a way to do that:

  1. Open a terminal and install wmctrl:

    sudo apt update
    sudo apt install wmctrl
  2. Create a shell script named show-desktop.sh (I put it in my home folder)

    gedit ~/show-desktop.sh

    Place this code in there:

    status="$(wmctrl -m | grep "showing the desktop" | sed -r 's/(.*)(ON|OFF)/\2/g')"
    if [ $status == "ON" ]; then
        wmctrl -k off
        wmctrl -k on

    ...and make it executable:

    chmod +x ~/show-desktop.sh
  3. Create a file named show-desktop.desktop in the ~/.local/share/applications/ folder:

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

    Add this text to it, and save the file (don't forget change the value on <your user>):

    [Desktop Entry]
    Name=Show Desktop
    Exec=/home/<your user>/show-desktop.sh
  4. Open the dash menu by pressing the Windows (Super) key, and search for the "show desktop" entry you just made above. Add it to your favorites menu.

  • 7
    Tested and working also on Ubuntu 18.04 LTS. This is the best way I've found to do it since they removed the 'Add show desktop icon to the launcher' option from System Settings / Appearance / Behaviour panel. It was such an useful feature. Sometimes I really do not understand Ubuntu developers...
    – bytepan
    Commented Apr 29, 2018 at 9:30
  • 4
    In the file "show-desktop.desktop" (topic 3), I changed "Icon=show-desktop" to "Icon=desktop",because the previous one was not working. Commented May 20, 2018 at 3:56
  • This is not beginner friendly. How do I create a file in the applications folder? I can't just create it and save it there through the gui because it's protected. Thanks.
    – Rabbit
    Commented Sep 1, 2018 at 12:06
  • 2
    @Rabbit you need to use root privileges. Open a terminal and type: sudo nano /use/share/applications/show-desktop.desktop
    – AndAC
    Commented Sep 1, 2018 at 12:10
  • 1
    @Rabbit I understand. I do think this could be better explained. Maybe someone with a better English could edit my post to make it easier for beginners.
    – AndAC
    Commented Sep 1, 2018 at 12:41

Update: see my new answer with my new instructions here instead.

Nevertheless, you still might find some useful information below.

Update 23 June 2023: wmctrl is better than xdotool

Use wmctrl as @AndAC says here, instead. wmctrl is superior to my xdotool solution because it works in the Wayland window manager too, not just X11. And, wmctrl is superior to ydotool (which works in Wayland too) because wmctrl doesn't require sudo nor a daemon, whereas ydotool requires a background daemon which must be started with sudo.

I have tested the wmctrl solution in Ubuntu 22.04.2 in both the X11 and Wayland window managers, and it works great to show and hide the windows/desktop in both!

See my 3 test files in my eRCaGuy_hello_world repo here:

  1. bash/show_desktop_with_wmctrl.sh
  2. bash/show_desktop_with_xdotool.sh
  3. bash/show_desktop_with_ydotool.sh

Original answer:

First off, know that keyboard shortcuts Super (Windows Key) + D, or Ctrl + Alt + D will toggle between showing/hiding the desktop. You may get used to this keyboard shortcut and decide it's better than clicking an icon anyway. Nevertheless, we can create a clickable shortcut which will simply do this keyboard shortcut for us to show/hide the desktop.

Note that I recommend using Option 1 [MY PREFERRED CHOICE] OR one of the methods from Option 2 below, but not both Option 1 and Option 2 together, as they seem to conflict in weird ways. Ie: if you set up Option 1 then set up one of the Option 2's, just remove the Show Desktop icon from Option 1 as a favorite, and stop using it. Weird things happen if you click the Show Desktop icon from Option 1 after installing one of the Option 2s. I think this is because xdotool (used by Option 1) is attempting to send messages to your system as though they came from your keyboard, so however the Option 2 methods work, they conflict with xdotool or something and sometimes your Super key or mouse keys seem to get "stuck" down simply by using both Options together. Note that this unusual and buggy behavior does NOT present itself, however, if you manually use the Super + D shorcut together with an Option 2 method, OR if you use just the Option 1 method and no Option 2 methods.

My recommendation is to use the Option 1 method below in conjunction with the Super (Windows Key) + D keyboard shortcut whenever you feel like using the keyboard shortcut instead.

This suits me the best.


Tested and works in Ubuntu 14.04, 16.04, 18.04, 20.04, 22.04, when using the X11 window manager, NOT Wayland.


  1. I've mentioned other bugs in Wayland here.
  2. To make a version of this that will work in Wayland in the future, you can use ydotool. I've written about that here (Press Windows + D in Wayland) and on my personal website here (Tutorial: Getting started with ydotool to automate key presses (or mouse movements) in Linux).

To use the X11 Window Manager in Ubuntu 20.04, 22.04, etc.:

  1. Log out of Ubuntu.

  2. At the login screen, click your username to begin typing your password.

  3. This enables a little gear icon in the bottom-right, to select your window manager. Click that to select your window manager. Choose the non-Wayland option! If currently set to the Wayland option, then it will show "Ubuntu" [which means Wayland in this case] and "Ubuntu on Xorg" [which means X11]. Choose the "Ubuntu on Xorg" option. Here is a screenshot:

    enter image description here

For additional screenshots and the most up-to-date info. in this, see my other answer here: Wayland window manager causes my computer to stay on a black/blank screen and not wake up

Now that you are using the X11 Window manager, the following will work:

Credit: I didn't come up with the following, Ubuntu genius & blogger Ji m did, here: http://ubuntuhandbook.org/index.php/2018/10/add-show-desktop-button-ubuntu-18-10-18-04/. I'm borrowing directly from his material (a lot of it quoted directly):

  1. "Open terminal (Ctrl + Alt + T) and install xdotool:"

    sudo apt install xdotool
  2. "Then create the show desktop shortcut icon and edit it via command:"

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

    "When the file opens, paste following lines and save it."

    [Desktop Entry]
    Name=Show Desktop
    Exec=xdotool key --clearmodifiers Super+d
  3. "Finally search for ‘show desktop’ in application menu, then right lick and select ‘add to favorites’:"

    "That’s it. Enjoy!"

    Here it is, as shown on my desktop:

    enter image description here

Option 2:

Option 2.A:

Click your "Start menu" icon thing (9-dot icon) and type in "show desktop." Wait a few seconds for search results to pop up, and click on and install one of the Gnome Shell extensions. (Note that these search results are simply coming from the Ubuntu Software center).

enter image description here

For more info on Gnome Shell Extensions, see my other answer here: https://askubuntu.com/a/1089033/327339.

Ex: here's the first one: enter image description here

Click the "Install" button and here's what it looks like on my desktop:

enter image description here

Option 2.B:

Here's another one [used to be my personal favorite, but then I switched back to Option 1 because it seems to work the smoothest and be the most consistent]:

enter image description here

And here's what it looks like installed: enter image description here

  • 1
    Option 2a and b don't seem to be available in 20.04 Focal. (Thanks for this! It's so helpful)
    – Rabbit
    Commented May 24, 2020 at 15:25

@AndAC has a great answer. I've upvoted it. I also have an older answer here.

I've added my own show_desktop.sh script and show-desktop.desktop file to my eRCaGuy_dotfiles repo today, however, and want to show how to use them. So, on any new computer I set up (which I do a lot of), this is now how I set up my "Show Desktop" icon on the computer:

How to install the Show Desktop executable & icon from my eRCaGuy_dotfiles repo

Tested on Ubuntu 22.04.2 with the Gnome desktop in both the X11 and Wayland window managers.

# 1. Install dependencies
sudo apt update
sudo apt install git wmctrl

# 2. get the whole repo

# this is where we will put this repo; you can choose any path you want
mkdir -p "$INSTALL_DIR"  
git clone https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles.git
cd eRCaGuy_dotfiles

# 3. Install the `show_desktop` command

# Install `show_desktop` into ~/bin/
mkdir -p ~/bin
. ~./profile  # for a default Ubuntu install, this adds ~/bin to your PATH
# Create a symlink to the script and place it in ~/bin/
# - NB: you must be `cd`ed into the "eRCaGuy_dotfiles/" dir that you just cloned
#   before running this cmd.
ln -si "$(pwd)/useful_scripts/show_desktop.sh" ~/bin/show_desktop
# Optional: create a version with your initials prefixed too (mine are `gs_`)
ln -si "$(pwd)/useful_scripts/show_desktop.sh" ~/bin/gs_show_desktop

# test it; this should show your desktop
# - manually press Windows + D to show your open windows again

# 4. Install the show-desktop.desktop launcher file
# - NB: you must be `cd`ed into the "eRCaGuy_dotfiles/" dir that you just cloned
#   before running this cmd.
ln -si "$(pwd)/home/Desktop_launchers/show-desktop.desktop" ~/.local/share/applications/

NB: with the symlink-based instructions above, you cannot delete the eRCaGuy_dotfiles repo.

Now, add the "Show Desktop" icon as a favorite to your launcher: press the Windows key --> search for "Show Desktop" --> right-click it and select "Add to Favorites". Then, in your favorites icons in the left bar in Ubuntu, drag it to where you'd like it (I like it at the very top, as the first icon from the top).

Here's what mine looks like on Ubuntu 22.04. It is the icon at the very top:

enter image description here

That's it. Enjoy! Simply click the icon to toggle showing/hiding your desktop, or press Windows (Super) + D to do the same thing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .