What is the quickest way to quickly disable the standby feature when closing the lid? I very much like this behaviour but especially when playing music, I would like to close my lid without switching my machine into standby.
However, I do not want to permanently disable this feature but just temporarily turn it off until I finished listening to music, for example.
Maybe there is an indicator similar to Caffeine?
The script below will toggle the close-lid action between "nothing" and "suspend":
...And notify what is the currently set state:
How to use
Simply:
toggle_lid.py
Add it to a shortcut key: choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:
Explanation
The current state of the close-lid action setting can be retrieved by the command(s)
(on power), and
(on battery)
The script reads the current state, and sets the opposite ('suspend'/'nothing') with the command:
Optionally (additionally)
Optionally/additionally, you can run an indicator as a detector to show what is the current state of the lid- setting. It will show:
...in the panel, if the suspend will be prevented on closing the lid, It will show a grey one if not.
The script
How to use
show_state.py
Copy both icons below (right click -> save as), and save them in one and the same directory as
show_proc.py
, and exactly named as indicated belowgreen.png
nocolor.png
Now test- run
show_state.py
by the command:and change the current state by pressing the shortcut you set the first section of this answer.
If all works fine, add the following to startup applications:
Note
The detector- indicator above is an edited version of this answer. Simply by changing the test in the function
runs()
(and optionally the according panel icons), you can use it to show the state of anything that isTrue
orFalse
.Another option would be changing from "Suspend" to "Do Nothing" in Ubuntu Settings - Power:
PS: This doesn't provide an indicator in the notifications area but is simpler than creating a script for new users.
PPS: In this screen snapshot the UPS is for Cable Modem + Sony Android TV, not the laptop which has battery... HAHA.