Suspend In Motion


Reader [Brien Schultz] didn’t like his laptop suspending every time he closed the lid to move around the house or to a different work area, so he turned that feature off. Of course that just led to him forgetting to put the thing to sleep when he really needed to, like when he was walking around all day with it in his backpack. To solve his self inflicted problem (common cause of many hacks) he wrote a .NET program to monitor the laptop’s accelerometer. The accelerometer is usually used to park the hard drive heads in case the laptop is falling (it’s also used for hilarity). If BedTime detects that the laptop is in motion, but is not being used it starts a countdown and eventually puts the laptop to sleep. Brien isn’t using the “sleep after X minutes” option because it would put the machine to sleep while it was open and he was just distracted for a few moments. Demo video after the break.

23 thoughts on “Suspend In Motion

  1. Absolutely brilliant! I have also forgotten to turn off my laptop >< and this is an almost flawless method to solve it. Putting accelerometers to a real good use... now just to make a laptop version of a wiimote...

  2. This is a really great product. ::Applause::

    My suggestion is to add a feature that allows it to go into Hibernation instead of sleep. As sleep does use power and it will drain over time.

    P.S. I have to agree with #3. I still havent figured it all out as a developer, but from a system viewpoint, it’s supposed to make everything easier.

    #4, it requires Dot.Net Framework, so no linux.

  3. #8: What about the Mono Project? I haven’t got that up and running yet, as I just switched to Ubuntu a few weeks ago, but it may well work on Linux with some tweaking…

  4. “it seems kind of counterintuitive. why not just make it go to sleep after a preset time when it is closed? how does the motion sensor help?”

    I don’t really get the point of it either. OK you close the lid and its moving, so it sets a 5min timer to go to sleep (long enough to get somewhere within the house).

    Now you close the lid later but its not moving, should it sleep then as well? Seems like it should.

    The idea and execution is cool, but it isn’t exactly a “brilliant” hack.

  5. yeah i wouldnt say that linux is the best OS out there, but it ain’t some crack-dealin’ weed-smokin’ pimp! I think that because of its 3rd party capabilities Linux isnt that bad (granted of course that you have Windows XP or Vista on your computer as well.)

    sure beats Mac’s iCrap series!

  6. You guys are missing the point. He DOESN’T want the laptop sleeping when he just shuts the lid. A lot of people use their laptops as their primary computers. I shut my screen a lot while still running applications in the background. Sleeping would kill those, this lets me not sleep all the time while still being able to pick up my laptop and go without worrying about the battery being dead when I get there.

  7. Why, oh why, not just set a sleep timer to ~3 minutes if the lid is closed?

    And what if I were to close the lid, and put the computer over in the corner of $somewhere, only to forget it for a couple of hours? Problem unsolved!

  8. Ok, so I finally got binaries and source uploaded. This is ALPHA!!! It might not work properly, I haven’t tested it properly yet.

    Binaries for ZIP people…
    http://www.suite304.com/BedTimeAlpha.zip

    And for the WinRAR people…
    http://www.suite304.com/BedTimeAlpha.rar

    Source for my .Net homies…
    http://www.suite304.com/BedTimeSource.zip

    If you want to help me make this better I’d appriciate it. This version is very basic and simple (as you will see).

  9. Oh, and towards the convo on this running on Linux, Apple, etc. …This program is so simple I could easily write it in C, C++, Java, etc. so I don’t think platforms will be a problem. I just need to get specs on all the APIs/drivers for accelerometers.

  10. This is creat idea. I’ve tryed to find a solution for FSC Notebooks. Google gives me these helpfull links:
    http://nich.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&_c=BlogPart&partqs=amonth%3d3%26ayear%3d2007
    http://geekswithblogs.net/dirksblog/articles/54935.aspx (german)
    http://msdn2.microsoft.com/En-US/library/aa363216.aspx

    finaly with that Information it was posible to write/modify a simple sample code.

    /* Reads Acceleration Sensor Values out of FSC Liefebook T4215
    and perhaps other FSC Notebooks that work with Shock Sensor
    Utility ( FJSSGUI.exe + FJSSDMN.exe )
    Sensor Description:
    http://www.fujitsu.com/sg/services/computing/pc/einfo/shock-sensor/

    Thanks to Nicholai Yu who did de reverse engineering:
    http://nich.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&_c=BlogPart&partqs=amonth%3d3%26ayear%3d2007
    and MSDN for their example source which I’ve just modified a little bit.
    http://msdn2.microsoft.com/En-US/library/aa363216.aspx

    To Port this to other HDD Sensors try http://www.rohitab.com/apimonitor/ and monitor
    the DeviceIoControl calls from an existing Sensor App.

    Note: This code is only tested on one maschine.
    !!!!!!Use it on your own risk!!!!!! and report if it works.
    Sorry about my bad english, have fun with the app.
    (I hope sombody built some nice tools or games like a port of this
    http://www.weiblespiele.de/images/79050.jpg for tablet PC ;)

    Some Keywords for Google:
    Shock Sensor Utility, hdd, harddisk, shock, Fujitsu, source, c,
    accelerometer, acceleration, motion, gyro, tilt, pan, protection
    */

    #include
    #include
    #include

    BOOL GetAccel(char *AccValue)
    {
    HANDLE hDevice; // handle to the drive to be examined
    BOOL bResult; // results flag
    DWORD junk; // discard results

    hDevice = CreateFile(TEXT(“\\\\.\\PhysicalDrive0”), // drive
    0, // no access to the drive
    FILE_SHARE_READ | // share mode
    FILE_SHARE_WRITE,
    NULL, // default security attributes
    OPEN_EXISTING, // disposition
    0, // file attributes
    NULL); // do not copy file attributes

    if (hDevice == INVALID_HANDLE_VALUE) // cannot open the drive
    {
    return (FALSE);
    }

    bResult = DeviceIoControl(hDevice, // device to be queried
    0x220208, // operation to perform

Leave a Reply to Ross PetersCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.