Jump to content

Autosleep-Script


  • Please log in to reply
164 replies to this topic

#81
FKA

FKA

    are we there yet?

  • Members
  • PipPipPipPipPipPipPipPipPipPip
  • 1,626 posts
  • Gender:Male

Anyway, i think a "nice gui" isn't necessary for this job ... :(


Absolutly - I use your RIP3 script - it loads at boot I don't see it, i don't want to see it - and now my system sleeps.

Thank you very much :P

#82
dino7777

dino7777

    InsanelyMac Geek

  • Members
  • PipPipPip
  • 111 posts

So its not yet free of charge? Look, if you want to spend some time, use it for developing your own scripts or apps instead of trolling around ... :angel:


M8,

i am in software business, but more in quality assurance. If you ever need some test manager and engineer, you can pm me :)

#83
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
:rolleyes: :D :D
Happy new year to everyone ....

#84
aleister Crowley

aleister Crowley

    InsanelyMac Protégé

  • Members
  • PipPip
  • 76 posts
THX for the new RIP3lanNet Script..exactly what i need :(

Besides, it was not Paragon NTFS Driver which stops AutoSleep...ofcourse it was my new LG BH10LS30 BluRay Burner/Combo Drive!
Auto Sleep was working fine "out of the Box" with my old DVD Drive.

The Problem is well known that a lot SATA Optical Drives prevent Auto Sleep, on "real" Macs too

However, this Script works fine....

#85
brightonroad

brightonroad

    InsanelyMac Protégé

  • Just Joined
  • Pip
  • 1 posts
Hi, thanks very much for this little beauty, solved a long term issue I had with timed sleep. Don't suppose you could advise how to add VLC?? (other than sleep resistant) but more like itunes/QT, when it's playing script stops.

#86
aleister Crowley

aleister Crowley

    InsanelyMac Protégé

  • Members
  • PipPip
  • 76 posts

Hi, thanks very much for this little beauty, solved a long term issue I had with timed sleep. Don't suppose you could advise how to add VLC?? (other than sleep resistant) but more like itunes/QT, when it's playing script stops.


mh...should be no Problem with VLC ? VLC produce CPU load so the Script wont send SL to sleep

#87
manmal

manmal

    InsanelyMac Sage

  • Members
  • PipPipPipPipPipPip
  • 437 posts
hi KWS,
thanks for the script.
Does it support auto-sleep when battery is low (lower than 2-3% or X% selectable) ? It happens that my computer powers off with low battery and i lose everything.
Mal

#88
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts

hi KWS,
thanks for the script.
Does it support auto-sleep when battery is low (lower than 2-3% or X% selectable) ? It happens that my computer powers off with low battery and i lose everything.
Mal

Not yet ... :)

#89
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
Try this one, it should send your machine to sleep if battery power is less than 3 % (if not charging) ... :)
Attached File  RIP3lanNetL.app.zip   35.6KB   14 downloads
Apparently there are more problems than expected with shellscripts, so here's a Laptop-Version with almost no shellscript, only one used in battery-monitoring.
However, you must now make use of the screensaver as a trigger, 5 s after screensaver-start the machine will go to sleep.
Sleep is prevented by playing in iTunes, DVD-Player, Quicktime or downloading to the Download-Folder on your home-directory.
Not included is monitoring LAN-Traffic or CPU-usage of Finder and other processes ...
Attached File  RIPsLAS.app.zip   29.64KB   17 downloads
here the version without battery-monitoring and bigger interval - 5 min from screensaver-start to sleep ...
Attached File  RIPsAS.app.zip   28.72KB   16 downloads
... and at last one ONLY for battery monitoring (sleep if battery power is less than 3 % (if not charging)
Attached File  BatteryMon.app.zip   26.29KB   35 downloads

#90
manmal

manmal

    InsanelyMac Sage

  • Members
  • PipPipPipPipPipPip
  • 437 posts

Try this one, it should send your machine to sleep if battery power is less than 3 %, i havent yet tested it .... ;)


Oh thanks! I will try it!
Does it go to sleep if it's under 3% and it's charging ? Or have you included the exception to exclude sleep-on-lowbattery when it's connected to acpower (ie. charging)?
thanks!
Mal

#91
kernnell

kernnell

    InsanelyMac Protégé

  • Members
  • PipPip
  • 91 posts
Hi, About running the script...

i just add to startup like my screen-capture, or am i missing something?

Attached Files



#92
kernnell

kernnell

    InsanelyMac Protégé

  • Members
  • PipPip
  • 91 posts
i'm asking because it didn't work that way.

Can someone me help, please?

#93
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
This small prog will show you some values necessary for functioning of RIP3 and save a logfile to your desktop
Attached File  RIPtest.app.zip   37.17KB   17 downloads
This is a second test, useful if the first went well. Save this prog to your desktop, start it and leave your mouse and keyboard untouched. Every 30 s you should see a dialog box with:
Time till sleep in sec
and
Sec since last input
Its useful to set Time till sleep in Syspref to a small amount. Time since last user input should continually grow (in 30s-steps), if the current value is smaller than the previous one theres some process in the background preventing sleep ...
To stop: Right-click on the prog-icon and select exit ...
Attached File  RIPtest2.app.zip   38.87KB   17 downloads

#94
gyozadude

gyozadude

    InsanelyMac Protégé

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:Sunnyvale, California
  • Interests:BBQ, Fishing, Volunteering with Scouts.
I assume you went to System Prefs -> Users then in the [login items] clicked the [+] at the bottom of the pane and added some version of this? Correct?

Then you must logout/login again to activate this (as well as having some short PowerSaver preference - I set mine to 1 minute for sleep).

My first attempt was blocked and didn't work. I was wondering why. And I figured out that the permissions for the effective User ID of the auto-sleep daemon must be someone other than my userid. Because it must not be accessing the application. I can't remember if this was in /var/log/system.log or in the Apps -> Utilities -> Console app. But I assumed it couldn't access this because of a directory/file permissioning problem (since I was pointing to the app sitting in my user home directory somewhere which is permissioned restrictively.

Solution was to su - root, then cp -pr RIP3*.app /Applications, then chown -R root:wheel.

Then include that for each user. But I figured that is brutally inefficient to do this for each user. Better solution is to leveral OS X launchd and figure out a way to globally put this into the system's launcher at startup and so it doesn't matter who's logged in or logged out. It always sleeps. Currently, if no one is logged in on the Hackintosh used by my Kids, the system won't sleep. It works great if they are logged in. I haven't looked at the script enough to see if there are any dependencies. But worth a try. Maybe KWS can weigh in? Is there a reason why we shouldn't put this into the system startup launchd?

i'm asking because it didn't work that way.

Can someone me help, please?



#95
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
2 years ago I made this only for my personal purpose. I am the only user on my hacks and so this problem was not important to me ... from my point of view its ok to put it into the system startup launchd ...

After some work on the topic I must unfortunately note that i assume it will not be possible to start THIS (my) script without further modifications by launchd. Right now I'm a little busy in my job, but maybe i work on it in the future ... ;)

#96
gyozadude

gyozadude

    InsanelyMac Protégé

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:Sunnyvale, California
  • Interests:BBQ, Fishing, Volunteering with Scouts.
Thanks for the opinion. Been reading up on how launchd works and it looks straightforward. If time permits, I'll give it a go and see if that works out.

2 years agobI made this only for my personal purpose. I am the only user on my hacks and so this problem was not important to me ... from my point of view its ok to put it into the system startup launchd ...



#97
gyozadude

gyozadude

    InsanelyMac Protégé

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:Sunnyvale, California
  • Interests:BBQ, Fishing, Volunteering with Scouts.
I tried to deploy the RIP3lanNet.app as a LaunchDaemon, but this failed and from the error, I think it was pertaining to no Graphics context when trying to access Application state. I got the feeling that some of the commands in AppleScript are GUI dependent, much like X/Motif/GUI dependencies that prevent some X apps from running if no windowing system is present - baffling because these requests for system service information like application state could simply return non-GUI data and not invoke GUI context.

No matter, I wrote a really simple shell script which I named sleepcheck.sh

======================================
#!/bin/sh

SYSIDLE=`/usr/sbin/ioreg -c IOHIDSystem | /usr/bin/perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,"\n";last}'| cut -d'.' -f1`

SLEEPSETTING=`/usr/bin/pmset -g | /usr/bin/perl -lane 'if(/ sleep/) {print $F[-1]*60; last;}'`

#echo "idle time = ${SYSIDLE} seconds"
#echo "sleep setting = ${SLEEPSETTING} seconds"

if [ ${SYSIDLE} -ge ${SLEEPSETTING} ]; then
/sbin/shutdown -s now
fi
======================================

Then I put this somewhere in my home directory and made it accessible and executable (chmod 755 both the directory I put it in and all parent directories too).

Then I su to root and edited the crontab file:

% su - root (enter root passwd)
# crontab -e

I added one line:

*/5 * * * * /Users/gyozadude/bin/sleepcheck.sh >> /dev/null 2>&1

(this runs every 5 minutes and executes the sleepcheck and redirects any script output and error output to /dev/null.)

It's working now. Thank goodness OS X is UNIX underneath. The hokey thing about Mac OS X is why the heck the regular sleep simply isn't calling "shutdown -s now" equivalent. There should never be the case that we can force sleep by clicking on the "Apple -> sleep" but when we set sysprefs -> user -> powersaver, the sleep doesn't work. Clearly, the implementation is fragile and therefore architecturally questionable. The fact is I can use command line to extract the time remain between HID events and idle time. This data is reliable and easy to get. So something within the launchd or GUI infrastructure is clearly over-complex and therefore incorrectly architected.

#98
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts
My solution came from the "far" other end. I work as a designer (unfortunately more dtp) and am familiar with Applescripts to shorten production processes.
But a additional problem is to prevent sleep during various circumstances (Network-activity, Quicktime, VLC) , so maybe it is possible to resolve that with a cpu-load query in combination with some in my script used shellscripts ... ?

#99
iFIRE

iFIRE

    InsanelyMacaholic

  • Moderators
  • 3,772 posts
  • Gender:Male
  • Location:Bcn-Spain

My solution came from the "far" other end. I work as a designer (unfortunately more dtp) and am familiar with Applescripts to shorten production processes.
But a additional problem is to prevent sleep during various circumstances (Network-activity, Quicktime, VLC) , so maybe it is possible to resolve that with a cpu-load query in combination with some in my script used shellscripts ... ?





PleazeSleep.app

#100
KWS

KWS

    InsanelyMac Protégé

  • Donators
  • 75 posts

PleazeSleep.app

... great Tip ...





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