0

I am using Plank on Ubuntu 14.04, I want to add "show desktop" shortcut to plank so that whenever I click it I get to see the desktop directly instead of minimizing all the windows. How can I do it?

Alex Jones
  • 7,982
  • 9
  • 55
  • 94

1 Answers1

1
  1. First of all install the xdotool:

    sudo apt-get install xdotool
    
  2. Create a Desktop Shortcut for the 'Show Desktop' for simulate the press key Win+D using xdotool:

    sudo nano /usr/share/applications/show-desktop.desktop
    

    Add below contents:

    [Desktop Entry]  
    Type=Application  
    Exec=xdotool key --delay 100 super+d  
    Name=Show Desktop  
    Icon=desktop  
    Terminal=false  
    StartupNotify=false  
    

    Or skip the boring edit part from above and enter this:

    echo -e "[Desktop Entry]\nType=Application\nExec=xdotool key --delay 100 super+d\nName=Show Desktop\nIcon=desktop\nTerminal=false\nStartupNotify=false" | sudo tee /usr/share/applications/show-desktop.desktop > /dev/null
    
  3. Create a Dockitem file in Phank:

    nano ~/.config/plank/dock1/launchers/show-desktop.dockitem
    

    The contents:

    [PlankItemsDockItemPreferences]  
    Launcher=file:///usr/share/applications/show-desktop.desktop  
    

    Or skip the boring edit part from above and enter this:

    /bin/bash -c 'echo -e "[PlankItemsDockItemPreferences]\nLauncher=file:///usr/share/applications/show-desktop.desktop" | tee ~/.config/plank/dock1/launchers/show-desktop.dockitem'
    
  4. Make It Permanent

    Now create a entry for the command above in gnome-session-properties. Because if accidentally make a mistake and remove the "Show Desktop" dockitem (uncheck 'Keep In Dock'), so you need to re-create the dockitem file again every time. To solve this problem, we just force to recreate the dockitem file on every session startup:

    echo -e "[Desktop Entry]\nType=Application\nExec=/bin/bash -c 'echo -e \"[PlankItemsDockItemPreferences]\\\nLauncher=file:///usr/share/applications/show-desktop.desktop\" | tee ~/.config/plank/dock1/launchers/show-desktop.dockitem'\nHidden=false\nX-GNOME-Autostart-enabled=true\nName=show-desktop-in-phank" | tee ~/.config/autostart/show-desktop-in-phank.desktop > /dev/null
    
Kulfy
  • 17,696
Maxwel Leite
  • 2,354
  • there are some spelling mistakes and errors in your code please review it, also I did all still its not working :-/ – Alex Jones Apr 26 '15 at 06:28
  • @edwardtorvalds, try this , I remake the whole procedure. Sorry my bad english, your help in this matter will be very appreciated! – Maxwel Leite Apr 27 '15 at 23:57
  • Hello, it doesn't behave correctly when I click on it. It either takes me to the unity dash or it hides all the windows. And when it hides all the windows, it doesn't let me unhide all the windows again. It is a bit bizarre. –  Jun 08 '17 at 00:08