A simple script to enable Windows-like "toggle show desktop" behavior in GNOME.
Install wmctrl:
# Debian/Ubuntu
sudo apt install wmctrl
# Fedora
sudo dnf install wmctrl
# Arch
sudo pacman -S wmctrl- Create the script directory and file:
mkdir -p ~/.local/bin
nano ~/.local/bin/toggle-desktop.sh- Copy the script content:
#!/bin/bash
if [ -f /tmp/desktop-shown ]; then
wmctrl -k off
rm /tmp/desktop-shown
else
wmctrl -k on
touch /tmp/desktop-shown
fi- Make it executable:
chmod +x ~/.local/bin/toggle-desktop.sh- Open Settings → Keyboard
- Scroll down and click "View and Customize Shortcuts" → "Custom Shortcuts"
- Click the "+" button
- Configure:
- Name: Toggle Show Desktop
- Command:
/home/yourusername/.local/bin/toggle-desktop.sh(replaceyourusernamewith your actual username) - Shortcut: Press Super + D (or your preferred combination)
Press Super + D (or what you chose) to minimize all windows and show desktop. Press it again to restore all windows.
The script uses wmctrl to show/hide the desktop and maintains state using a temporary flag file (/tmp/desktop-shown) to track whether windows are currently minimized.