If you just want the script, skip the explanation
You'll have to learn at least an appropriate programming (/scripting) language, but then:
Introduction; dconf and gsettings
Most (if not all) of the settings, edited by Unity Tweak Tool edit the dconf database, in which many settings are stored. Editing the dconf database is best done via gsettings, which is in fact a
cli-front end to the dconf database.
In your example, setting/toggling hotcorners can unfortunately only be done by editing the
dconf database directly, because there is no
SCHEMA available in
gsettings for it.
Getting the current value
The hotcorners -plugin is set in:
You can read the current state by the command:
dconf read /org/compiz/profiles/unity/plugins/core/show-desktop-edge
This will have an output in your case like (from your comment):
Setting a new value
To disable hotcorners, you need to run the command:
dconf write /org/compiz/profiles/unity/plugins/core/show-desktop-edge "''"
to (re-) enable hotcorners, with your previously set hotcorner:
dconf write /org/compiz/profiles/unity/plugins/core/show-desktop-edge "'|BottomRight'"
The anatomy of a toggle script
What the script (in general) should do:
- Test what is the current state A/B
- If the current state is A -> set B
- If the current state is B -> set A
In the script the steps above are described in the comments:
key = "/org/compiz/profiles/unity/plugins/core/show-desktop-edge"
val_on = "'|BottomRight'"
# read the current setting
return subprocess.check_output(["dconf", "read", key]).decode("utf-8").strip() == val_on
currstate = test()
if currstate == True:
# if currently hotcorners are "on", set it to "''"
newval = "''"
# if currently hotcorners are "off", set it to val_on
newval = val_on
subprocess.Popen(["dconf", "write", key, str(newval)])
How to use
- Copy the script into an empty file, save it as
Test- run it from a terminal:
If all works fine, add it to a keyboard shortcut. Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:
How can I see what the Unity Tweak Tool is editing?
Not only for Unity Tweak Tool, but also to see what System Settings is editing, in many cases the following gives you usefull information:
- Open a terminal, open Unity Tweak Tool
- Run the command
dconf watch / in the terminal
- Change the value from GUI in Unity Tweak Tool
The output in the terminal changes:
You can see what happens if I disable/enable hotcorners in Unity Tweak Tool.