Mike Kazantsev wrote:
> On Wed, 11 Mar 2009 18:41:56 -0400
> Saphirus Sage <saphirus...@gmail.com> wrote:
>
>   
>> The issue I've run into is that this will cause my laptop to suspend to
>> the RAM upon any change in the lid state, irregardless of if it is open
>> or closed. I tried to be more specific by utilizing the suffix of the
>> event, but it's incremental, which is a bit beyond my abilities. Any
>> suggestions to make this suspend only when the lid is closed?
>>     
>
> This one seem to be working for me:
>
>   #!/bin/sh
>   if grep closed /proc/acpi/button/lid/LID0/state &>/dev/null
>   then echo "Lid closed, suspending..."
>   else echo "Lid is open, doing nothing"
>   fi
>
>
> Then, you can just put it to, say, crontab, with a line like this:
>
>   */5 * * * * /path/to/script.sh
>
> ...which'll make it run every five minutes, so the laptop will be
> suspended within five mins of closing the lid, which should also
> prevent accidental closing events.
>
>
> Of course, you should put your actions to the aforementioned script, if
> you want it to do something useful, instead of just experimental echo
I'd considered using a crontab entry, it just seemed so inefficient in
comparison. However, I used the little chunk you provided as you've
suggested and it works well enough now, thanks. Apparently, after
researching it a bit, there are numerous bugs with acpi, which may
explain why the state in /proc/acpi/buttons/lid/LID/state would seem to
hang for a couple minutes, or until a restart. Still, thanks again.

Reply via email to