Computer States

B

Brandon B.

Hey all,

I'm looking for a way to programmatically wake the computer up from
sleep state, preferably at a certain time, rather than after certain
amount of time, but ill make due with whatever solution there might be.
any suggestions or help is much appreciated. i've been searching for a
couple weeks on and off for a way to do this, and can only find the
wake-on-lan, or wake-on wan (would work fine for some, but id rather
this feature not fail should the user not have a router or an internet
connection.)

Thanks in Advance,

X
 
D

David Masover

I'm looking for a way to programmatically wake the computer up from
sleep state, preferably at a certain time, rather than after certain
amount of time, but ill make due with whatever solution there might be.

I suspect most BIOSes have this feature, but I have no idea how to access it
programmatically. I did find this:

http://sourceforge.net/projects/nvram-wakeup/

I have no idea how well it works, though, and it's probably going to be
system-specific.
 
B

Brandon B.

I suspect most BIOSes have this feature, but I have no idea how to
access it

i was thinking about bios features, but being able to access and change
certain features of it will either give the user alot of hassle or
myself in having to change things on the many different bios versions
there are, if it is even possible to change it programmatically, not to
mention the warning label that would have to be included by going that
route.

will definetly have to check this out, might be able to salvage
something from it, with a bit of research.
I have no idea how well it works, though, and it's probably going to be
system-specific.

i would like to have it be cross-platform, but i dont have a problem
with testing for the OS is need be, thanks David.
 
P

Phillip Gawlowski

i was thinking about bios features, but being able to access and change
certain features of it will either give the user alot of hassle or
myself in having to change things on the many different bios versions
there are, if it is even possible to change it programmatically, not to
mention the warning label that would have to be included by going that
route.

You probably want to access http://en.wikipedia.org/wiki/ACPI
How you do that is OS specific, since it's fairly lowlevel. A very
superficial search for "Ruby ACPI library" didn't produce any real hits,
so it might be that you have to go low level to call the Windows, Linux,
and Mac OS X APIs for ACPI.

However, it is my understanding that ACPI can't wake a computer from a
Hibernating/Suspend to Disk (ACPI S4) from within the sleep state.

Hope this helps at least a little.
 
B

Brandon B.

You probably want to access http://en.wikipedia.org/wiki/ACPI
How you do that is OS specific, since it's fairly lowlevel. A very
superficial search for "Ruby ACPI library" didn't produce any real hits,
so it might be that you have to go low level to call the Windows, Linux,
and Mac OS X APIs for ACPI.

yea, i expected as much, which if fine, i just dont know how to go about
doing so... maybe there is a way to send a "wake-up" packet to the ram,
or nvram, and have it execute it from there at a given time? dont know
too much about what can and cant be performed like that so, if im way
off base, please forgive me.
However, it is my understanding that ACPI can't wake a computer from a
Hibernating/Suspend to Disk (ACPI S4) from within the sleep state.
Hope this helps at least a little.

yea it has helped, thank you. i have found a linux wake up procedure
that i might be able to tether to my needs, if it works

<CODE>
#!/usr/bin/ruby
require 'time'
wake_time = Time.parse(ARGV[0])
wake_time += 24 * 60 * 60 if wake_time < Time.now
File.open('/proc/acpi/alarm', 'w') {|f| f << wake_time.utc.strftime
(%Y-%m-%d %H:%M:%S')}
system('/etc/acpi/sleep.sh force')
</CODE>

like i said, this is for linux, obviously, which if it works takes out
one of my issues, but what i dont know is if there is anything like the
above file locations for windows or mac?

well, ill keep looking around, maybe i can dig up something else using
this as a search tool, any additional help or advice is much
appreciated.
 
P

Phillip Gawlowski

yea, i expected as much, which if fine, i just dont know how to go about
doing so... maybe there is a way to send a "wake-up" packet to the ram,
or nvram, and have it execute it from there at a given time? dont know
too much about what can and cant be performed like that so, if im way
off base, please forgive me.

You'd've to read the ACPI spec, I'm afraid, what does what, if you want
to go really, really low level, since I stay away from the Dark Arts. ;)
like i said, this is for linux, obviously, which if it works takes out
one of my issues, but what i dont know is if there is anything like the
above file locations for windows or mac?

With Windows, there's the win32api gem (pre-installed in the Once Click
Installer and/or the new RubyInstaller), providing access to the Windows
API, so you can call the Windows system calls to send the computer to
sleep. Or, maybe, you can shell out to "shutdown", but I'm not well
versed in Windows CLI tools, at least to send to computer to sleep. I'm
pretty sure that WakeOn needs an API call, though.

With Macs, and this is from my dim memory, there's CocoaRuby (I think
that's what it is called, googling for "cocoa ruby" should unearth
something), which accomplishes roughly the same as the win32api gem.

Keep in mind, you can run into binary compatibility issues on Windows
(depending on the Ruby variant installed, there's mswin32, and mingw32,
the latter being included in the new RubyInstaller), as well as on Mac
(depending on the Mac Os X API changes).

And that ain't even touching on JRuby. So, "true" cross-platform
compatibility will be difficult, to say the least.

Mind, just pick the Ruby versions you are able to report, and you'll be
fine, don't let me scare you. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top