Gentoo Archives: gentoo-user

From: Saphirus Sage <saphirus497@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Bash and ACPI issue - laptop lid
Date: Thu, 12 Mar 2009 01:35:41
Message-Id: 49B866EA.9060003@gmail.com
In Reply to: Re: [gentoo-user] Bash and ACPI issue - laptop lid by Mike Kazantsev
1 Mike Kazantsev wrote:
2 > On Wed, 11 Mar 2009 18:41:56 -0400
3 > Saphirus Sage <saphirus497@×××××.com> wrote:
4 >
5 >
6 >> The issue I've run into is that this will cause my laptop to suspend to
7 >> the RAM upon any change in the lid state, irregardless of if it is open
8 >> or closed. I tried to be more specific by utilizing the suffix of the
9 >> event, but it's incremental, which is a bit beyond my abilities. Any
10 >> suggestions to make this suspend only when the lid is closed?
11 >>
12 >
13 > This one seem to be working for me:
14 >
15 > #!/bin/sh
16 > if grep closed /proc/acpi/button/lid/LID0/state &>/dev/null
17 > then echo "Lid closed, suspending..."
18 > else echo "Lid is open, doing nothing"
19 > fi
20 >
21 >
22 > Then, you can just put it to, say, crontab, with a line like this:
23 >
24 > */5 * * * * /path/to/script.sh
25 >
26 > ...which'll make it run every five minutes, so the laptop will be
27 > suspended within five mins of closing the lid, which should also
28 > prevent accidental closing events.
29 >
30 >
31 > Of course, you should put your actions to the aforementioned script, if
32 > you want it to do something useful, instead of just experimental echo
33 I'd considered using a crontab entry, it just seemed so inefficient in
34 comparison. However, I used the little chunk you provided as you've
35 suggested and it works well enough now, thanks. Apparently, after
36 researching it a bit, there are numerous bugs with acpi, which may
37 explain why the state in /proc/acpi/buttons/lid/LID/state would seem to
38 hang for a couple minutes, or until a restart. Still, thanks again.