No shutdown option for critically low battery [SOLVED]

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Locked
User avatar
Pjotr
Level 21
Level 21
Posts: 14577
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

No shutdown option for critically low battery [SOLVED]

Post by Pjotr »

In Cinnamon (17.2 Rafaela), I would like to set Power Manager to "shutdown" when the battery is critically low. However, I have no such option in its settings.

So I've tried using dconf and ploughed my way to org - cinnamon - settings-daemon - plugins - power.
There I set critical-battery-action to "shutdown". This doesn't register in the settings GUI for Power Manager, though.... It simply throws up a blank then, for the "critically low battery" setting.

What can I try next? Any thoughts, suggestions or inklings (however vague) are welcome. :)
Last edited by Pjotr on Tue Aug 04, 2015 5:30 pm, edited 1 time in total.
Tip: 10 things to do after installing Linux Mint 19.3 Tricia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

Cosmo.
Level 23
Level 23
Posts: 17825
Joined: Sat Dec 06, 2014 7:34 am

Re: Power Manager: no shutdown option for critically low bat

Post by Cosmo. »

Out of reasons discussed on another place I use 17.2 only in a VM, where this matter is not applicable. So I am not able to see, which options you have at all in the GUI. Do you please tell me?

A shot in the dark: On Github a found a confirmed bug (most likely regarding Cinnamon 2.4), which applied only on higher versions of the kernel. It is only a wild guess (but at now the only one which comes to my mind), but perhaps this is the case here? So: Do you use the the recommended kernel or another (newer) one?

User avatar
Pjotr
Level 21
Level 21
Posts: 14577
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Power Manager: no shutdown option for critically low bat

Post by Pjotr »

This is a screenshot of the settings GUI, after I've used dconf-editor to set it to "shutdown" (click on the image to enlarge it):
Image

The only other option except blank, is "Do nothing" (there also used to be the option "Hibernate", but I've disabled hibernation on that machine).

The kernel is the recommended one for Mint 17.2:

Code: Select all

pjotr@Aspire-E3-111 ~ $ uname -r
3.16.0-38-generic
The GitHub bug report doesn't look related....
Tip: 10 things to do after installing Linux Mint 19.3 Tricia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

Cosmo.
Level 23
Level 23
Posts: 17825
Joined: Sat Dec 06, 2014 7:34 am

Re: Power Manager: no shutdown option for critically low bat

Post by Cosmo. »

I did not say, that it is related. My dark shot was, that this culprit could be also apply here.

User avatar
Pjotr
Level 21
Level 21
Posts: 14577
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Power Manager: no shutdown option for critically low battery

Post by Pjotr »

*bump*

Anyone else with ideas or inklings about this?
Tip: 10 things to do after installing Linux Mint 19.3 Tricia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

Laurent85
Level 16
Level 16
Posts: 6420
Joined: Tue May 26, 2015 10:11 am

Re: Power Manager: no shutdown option for critically low bat

Post by Laurent85 »

For some reasons the option to shutdown computer on battery critically low is missing.
Currently the code is

Code: Select all

sed -n '/ \{4\}critical_options =/,+3p' /usr/lib/cinnamon-settings/modules/cs_power.py
Command returns
critical_options = [
("hibernate", _("Hibernate")),
("nothing", _("Do nothing"))
]
A temporary fix to add shutdown option, use copy and paste to avoid a mistake.

Code: Select all

sudo sed -i '/critical_options =/,+1 {s/("hibernate", _("Hibernate")),/&\n        ("shutdown", _("Shutdown immediately")),/}' /usr/lib/cinnamon-settings/modules/cs_power.py
The code should then read

Code: Select all

sed -n '/ \{4\}critical_options =/,+4p' /usr/lib/cinnamon-settings/modules/cs_power.py
Command should return
critical_options = [
("hibernate", _("Hibernate")),
("shutdown", _("Shutdown immediately")),
("nothing", _("Do nothing"))
]
Try it, should work now.
Image

User avatar
Pjotr
Level 21
Level 21
Posts: 14577
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: No shutdown option for critically low battery [SOLVED]

Post by Pjotr »

@Laurent85: merveilleux! Merci beaucoup. :)
Tip: 10 things to do after installing Linux Mint 19.3 Tricia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

Laurent85
Level 16
Level 16
Posts: 6420
Joined: Tue May 26, 2015 10:11 am

Re: No shutdown option for critically low battery [SOLVED]

Post by Laurent85 »

Merci Pjotr :)
Image

gordonthegopher
Level 1
Level 1
Posts: 17
Joined: Wed Dec 10, 2014 7:10 pm

Re: No shutdown option for critically low battery [SOLVED]

Post by gordonthegopher »

Same bug 17.3 and the above code doesn't work...

Laurent85
Level 16
Level 16
Posts: 6420
Joined: Tue May 26, 2015 10:11 am

Re: No shutdown option for critically low battery [SOLVED]

Post by Laurent85 »

Command allowing immediate shutdown option for LM 17.3:

Code: Select all

sudo sed -i '/critical_options =/,+1 {s/("hibernate", _("Hibernate")),/&\n        ("shutdown", _("Shutdown immediately")),/}' /usr/share/cinnamon/cinnamon-settings/modules/cs_power.py
Image

gordonthegopher
Level 1
Level 1
Posts: 17
Joined: Wed Dec 10, 2014 7:10 pm

Re: No shutdown option for critically low battery [SOLVED]

Post by gordonthegopher »

Thanks Laurent85! Worked a treat.

sverx
Level 2
Level 2
Posts: 56
Joined: Mon Oct 02, 2017 4:58 am

Re: No shutdown option for critically low battery [SOLVED]

Post by sverx »

Sorry to 'revive' an old and solved topic, but I feel my point belongs here anyway.

To add "Ask what to do" to the list of possible options for when the battery is at critical level, can I simply edit cs_power.py adding

Code: Select all

("interactive", _("Ask what to do")),
to critical_options so that it becomes

Code: Select all

critical_options = [
("hibernate", _("Hibernate")),
("interactive", _("Ask what to do")),
("nothing", _("Do nothing"))
]
correct?

Will it simply suffice this edit (and of course to open the power options panel and set the desired entry)?

That would be wonderful, as I'm searching for a solution to both notify I didn't pay enough attention (!!!) and to leave me the option to either save and turn off, or to run for the charger... after all I should anyway have a few minutes left, right? :roll:

User avatar
Moem
Level 20
Level 20
Posts: 10649
Joined: Tue Nov 17, 2015 9:14 am
Location: The Netherlands
Contact:

Re: No shutdown option for critically low battery [SOLVED]

Post by Moem »

Please start a new thread. It'll get you more eyeballs too. Link to this one for reference, if you feel the need.
Image

If your issue is solved, kindly indicate that by editing the first post in the topic, and adding [SOLVED] to the title. Thanks!

Locked

Return to “Cinnamon”