Jump to content

Shutdown on low battery


nofearl
 Share

13 posts in this topic

Recommended Posts

a quick script that checks the battery level every 2mins and shutdowns the computer if its less than 3%

 

copy batterysave to /bin

copy plist file to /System/Library/LaunchDaemons/

 

run

 

sudo su -
chmod +x /bin/batterysave
chown root:wheel /System/Library/LaunchDaemons/com.nofearl.batterysave.plist

 

and restart...

 

it uses "shutdown -h now" and its not graceful (you will loose unsaved document)

 

but since the sleep is not working for me, better than depleting and possibly damaging the battery..

 

batterysave.zip

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

 

hi guyz,

thanks for the script and for the link!

 

I have 2 questions about this topic:

 

1) is it possible to change the batterysave script to force it to go to "sleep" instead of shutdown? How could it be done? I can't find any hibernate or sleep command like shutdown... I ask because in my system, although sleep works, it doesn't go automatically in sleep when battery is low (i don't know where is the preference to control/adjust that ... if anyone knows it, please let me know because it's what i am looking for now... thanks -_- )

 

2) I know there is smartsleep that should do that, but in my system it doesn't work. The question is : Is it possible to "force" SmartSleep to use hibernatemode 5 instead of 1 for hibernating ? it uses hibernatemode 1 by default and with this mode hibernatemode here doesn't work (also unchecking secure virtual memory under preferences-security). Here mode5 works, mode1 not and that's the reason why i am asking... the smartmode is the option i am looking for, if i just can replace hibernatemode=5,instead of hibernatemode=1 set by default by smartmode in smartsleep.

 

Thanks in advance!

Mal

Link to comment
Share on other sites

is it possible to change the batterysave script to force it to go to "sleep" instead of shutdown? How could it be done? I can't find any hibernate or sleep command like shutdown... I ask because in my system, although sleep works, it doesn't go automatically in sleep when battery is low (i don't know where is the preference to control/adjust that ... if anyone knows it, please let me know because it's what i am looking for now... thanks ;) )

Sure it could be done. Here is an effort to make it sleep instead of shutdown. It is untested though.

batterysleep.zipAlso, use this next one if u 'd like to make your machine go to hibernate instead, while preserving on-demand sleep mode.

batteryhibernate.zip

Greetz

  • Like 1
Link to comment
Share on other sites

  • 3 months later...
Sure it could be done. Here is an effort to make it sleep instead of shutdown. It is untested though.

batterysleep.zipAlso, use this next one if u 'd like to make your machine go to hibernate instead, while preserving on-demand sleep mode.

batteryhibernate.zip

Greetz

 

hello i am about to try ur script. But i got a question which you set hibernation mode to 1 in the beginning and return to mode 3 when executing the script. Is it necessary to change mode from 1 to 3? since my hibernation mode is 3.

Edit: I v tried the Script for Hibernation. The script executed well however it did not send machine to Hibernation but to Sleep.

 

Finally i got the last thing that my laptop should work like mac. My Laptop hibernate when battery is low. sleeps like usual. I achieved via Ur script and App Smartsleep

Thanks

Link to comment
Share on other sites

Sure it could be done. Here is an effort to make it sleep instead of shutdown. It is untested though.

batterysleep.zipAlso, use this next one if u 'd like to make your machine go to hibernate instead, while preserving on-demand sleep mode.

batteryhibernate.zip

Greetz

 

 

The sleep mode works pretty well on mine ASUS 1201n, thank you very much!!

Link to comment
Share on other sites

  • 7 years later...

Very cool. Is any of the sleep or hibernate scripts still known to work in macOS High Sierra 10.13.6?

On 11/4/2010 at 5:38 PM, mightycrown said:

Auto deepsleep when bat low.

The script and the utility are attached. How to is in Readme.

Please report the result.

Note: I m assuming that you have already got Deepsleep to work:)

AutoDeepsleep.zip

/Applications/Utilities/deepsleep ; exit;
dyld: lazy symbol binding failed: Symbol not found: _IOPMCopyActivePowerProfiles
  Referenced from: /Applications/Utilities/deepsleep
  Expected in: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit

dyld: Symbol not found: _IOPMCopyActivePowerProfiles
  Referenced from: /Applications/Utilities/deepsleep
  Expected in: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit

Abort trap: 6
logout

 

Edited by BugsB
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
 Share

×
×
  • Create New...