This simply tutorial shows how to add a ‘Show Desktop‘ icon into the left dock panel in Ubuntu 21.10, Ubuntu 20.04, or Ubuntu 18.04 with default GNOME desktop.
The ‘Show Desktop‘ button was dropped since Ubuntu switched to Gnome 3 Desktop. For those using desktop app shortcuts, it’s useful to have a button to toggle display blank desktop quickly. And to add it back, you can manually create shortcut icon to do the trick and add it to panel (dock).
As you may know, the keyboard shortcuts Ctrl+Alt+d
or Super+d
do the function hide or show all opened app windows. And following steps will create a ‘show desktop’ shortcut icon simulates the keyboard press (Super+d
) via the xdotool
tool.
NOTE that following steps don’t work on Wayland session, since xdotool simulates X11 keyboard/mouse input events.
1. Install xdotool:
Xdotool is a command-line X11 automation tool, that allows to simulate keyboard input and mouse activity, move and resize windows, etc.
To install it, open terminal either by pressing Ctrl+Alt+T key combination on keyboard, or by searching from the activities overview screen. When terminal opens, paste the command below into it and hit run:
sudo apt-get install xdotool
Type your user password (no asterisk feedback) when it prompts and answer y to confirm.
2. Create a shortcut icon for Show Desktop:
Most Linux distributions identify app shortcut icons via .desktop file under “/usr/share/applications” for global or ‘.local/share/applications’ for local user only.
To create an app shortcut in the case, run command in terminal:
gedit ~/.local/share/applications/show-desktop.desktop
This command will create and also open it via gedit text editor. When the file opens, copy and paste the lines below and save it.
[Desktop Entry]
Type=Application
Name=Show Desktop
Icon=desktop
Exec=xdotool key --clearmodifiers Super+d
3. Add show desktop to dock panel:
After created the shortcut, either press Windows (or Super) key on keyboard or click upper-left corner ‘Activities’ to bring up the overview screen.
Then search for ‘Show Desktop’ (without quotes), right-click on the result icon and select ‘Add to Favorites’.
Finally, you’ll see the ‘Show Desktop’ icon on the dock panel. As mentioned, it works only on Xorg session. For Ubuntu 21.04 and higher, you may need to choose ‘Ubuntu on Xorg‘ from the login screen via the gear button.
That’s all. Enjoy!