Jump to content

Shutdown on low battery


  • Please log in to reply
9 replies to this topic

#1
nofearl

nofearl

    InsanelyMac Protégé

  • Members
  • PipPip
  • 71 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..

Attached File  batterysave.zip   2.27KB   144 downloads

#2
booger_sniffer5000

booger_sniffer5000

    InsanelyMac Legend

  • Members
  • PipPipPipPipPipPipPip
  • 778 posts
  • Gender:Male
  • Location:US
  • Interests:OSx86 (duh)
Very nice script.

#3
chewanik

chewanik

    InsanelyMac Protégé

  • Members
  • Pip
  • 9 posts
Thanks buddy, keep up the good work!

#4
ehunt123

ehunt123

    InsanelyMac Protégé

  • Validating
  • Pip
  • 13 posts
http://www.jinx.de/SmartSleep.html

#5
manmal

manmal

    InsanelyMac Sage

  • Members
  • PipPipPipPipPipPip
  • 437 posts

http://www.jinx.de/SmartSleep.html


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

#6
valv

valv

    InsanelyMac Architect

  • Members
  • PipPipPipPipPipPipPip
  • 910 posts
  • Gender:Male
  • Location:Unrevealed Area
  • Interests:Operating Systems<br />Networking<br />Security

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.
Attached File  batterysleep.zip   2.94KB   72 downloadsAlso, use this next one if u 'd like to make your machine go to hibernate instead, while preserving on-demand sleep mode.
Attached File  batteryhibernate.zip   2.96KB   64 downloads
Greetz

#7
mightycrown

mightycrown

    InsanelyMac Protégé

  • Members
  • PipPip
  • 90 posts

Sure it could be done. Here is an effort to make it sleep instead of shutdown. It is untested though.
Attached File  batterysleep.zip   2.94KB   72 downloadsAlso, use this next one if u 'd like to make your machine go to hibernate instead, while preserving on-demand sleep mode.
Attached File  batteryhibernate.zip   2.96KB   64 downloads
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

#8
TiGuy82

TiGuy82

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 127 posts
  • Location:Toronto, Canada

Sure it could be done. Here is an effort to make it sleep instead of shutdown. It is untested though.
Attached File  batterysleep.zip   2.94KB   72 downloadsAlso, use this next one if u 'd like to make your machine go to hibernate instead, while preserving on-demand sleep mode.
Attached File  batteryhibernate.zip   2.96KB   64 downloads
Greetz



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

#9
sefsesas

sefsesas

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 5 posts
Thanks for your scripts,now some laptop already can auto turn to sleep when battery is lowPosted Image

#10
mightycrown

mightycrown

    InsanelyMac Protégé

  • Members
  • PipPip
  • 90 posts
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:)

Attached Files







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy