How to make the hot corner show desktop and restore windows

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
User avatar
Zorba
Level 8
Level 8
Posts: 2281
Joined: Tue May 29, 2012 10:12 pm
Location: Tunisia

How to make the hot corner show desktop and restore windows

Postby Zorba » Fri Mar 07, 2014 5:28 am

1- Solution 1:

a- install wmctrl

Code: Select all

sudo apt-get install wmctrl


b- go to " hot corners" in the s"ystem setting" and set two hot corners to custom and in one box enter:

Code: Select all

wmctrl -k on

and in the other enter:

Code: Select all

wmctrl -k off


the first will show your desktop and the other will restore windows :D

2- Solution two:

a- install wmctrl

Code: Select all

sudo apt-get install wmctrl


b- create a script with the following content and make it excutable:

Code: Select all

#!/bin/bash

current_mode="$(wmctrl -m | grep 'showing the desktop')"

if [[ "${current_mode##* }" == ON ]]; then
    wmctrl -k off
else
    wmctrl -k on
fi


c- name it "showdesktop" (or whatever you want) and place it in your home folder or somewhere safe then give the directory to this script in the hot corner box in your system settings. For example, I put it in my home folder and made it hidden by placing a period before it like this:

Code: Select all

/home/mint/.showdesktop


Image

now the same corner will do both :D



Explanation of above code:

Code: Select all

#!/bin/bash

This is a shebang comment.

Code: Select all

current_mode="$(wmctrl -m | grep 'showing the desktop')"

This captures the output of wmctrl -m piped through grep 'showing the desktop' into the variable $current_mode.

Code: Select all

if [[ "${current_mode##* }" == ON ]]; then
    wmctrl -k off
else
    wmctrl -k on
fi

An if...else... statement in Bash. ${current_mode##* } returns $current_mode with the longest match of anything up until a space deleted from the front of the string. If this returns ON, turns desktop off; else turns desktop on. :D :D
Image

gusti
Level 1
Level 1
Posts: 1
Joined: Tue May 06, 2014 1:08 pm

Re: How to make the hot corner show desktop and restore wind

Postby gusti » Tue May 06, 2014 1:15 pm

or you can try toggle it

Code: Select all

#!/bin/sh

TOGGLE=$HOME/.toggle

if [ ! -e $TOGGLE ]; then
        touch $TOGGLE
        wmctrl -k off

else
        rm $TOGGLE
        wmctrl -k on

fi

User avatar
Zorba
Level 8
Level 8
Posts: 2281
Joined: Tue May 29, 2012 10:12 pm
Location: Tunisia

Re: How to make the hot corner show desktop and restore wind

Postby Zorba » Tue May 06, 2014 7:33 pm

This feature is included by default in Cinnamon 2.2 and so n Linux Mint17 :D
Image

dazz13
Level 1
Level 1
Posts: 1
Joined: Mon Jul 28, 2014 3:50 pm

Re: How to make the hot corner show desktop and restore wind

Postby dazz13 » Mon Jul 28, 2014 3:53 pm

But my use case is, I want to go to the corner, see the desktop, select an image, go back to the corner to unhide the desktop, and drop the image in the browser. When I got to the corner while dragging an image, it does not activate the hot corner. :?: :cry:


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 3 guests