* [gentoo-user] Bash and ACPI issue - laptop lid @ 2009-03-11 22:41 Saphirus Sage 2009-03-12 0:42 ` Mike Kazantsev 2009-03-12 12:13 ` Sebastian Günther 0 siblings, 2 replies; 4+ messages in thread From: Saphirus Sage @ 2009-03-11 22:41 UTC (permalink / raw To: gentoo-user I've been trying to setup my laptop to enter ACPI S3 (suspend to ram) when I close the lid. I currently have the scripts setup as such: /etc/acpi/events/lid event=button[ /]lid.* action=/etc/acpi/actions/lid.sh /etc/acpi/actions/lid.sh #!/bin/bash for i in $(cat /proc/acpi/button/lid/LID/state | grep -o closed); do if [ $i = "closed" ]; then /usr/sbin/pm-suspend fi if [ $i != "closed" ]; then sleep 5 fi done 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? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Bash and ACPI issue - laptop lid 2009-03-11 22:41 [gentoo-user] Bash and ACPI issue - laptop lid Saphirus Sage @ 2009-03-12 0:42 ` Mike Kazantsev 2009-03-12 1:35 ` Saphirus Sage 2009-03-12 12:13 ` Sebastian Günther 1 sibling, 1 reply; 4+ messages in thread From: Mike Kazantsev @ 2009-03-12 0:42 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 1118 bytes --] On Wed, 11 Mar 2009 18:41:56 -0400 Saphirus Sage <saphirus497@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. -- Mike Kazantsev // fraggod.net [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Bash and ACPI issue - laptop lid 2009-03-12 0:42 ` Mike Kazantsev @ 2009-03-12 1:35 ` Saphirus Sage 0 siblings, 0 replies; 4+ messages in thread From: Saphirus Sage @ 2009-03-12 1:35 UTC (permalink / raw To: gentoo-user Mike Kazantsev wrote: > On Wed, 11 Mar 2009 18:41:56 -0400 > Saphirus Sage <saphirus497@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. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Bash and ACPI issue - laptop lid 2009-03-11 22:41 [gentoo-user] Bash and ACPI issue - laptop lid Saphirus Sage 2009-03-12 0:42 ` Mike Kazantsev @ 2009-03-12 12:13 ` Sebastian Günther 1 sibling, 0 replies; 4+ messages in thread From: Sebastian Günther @ 2009-03-12 12:13 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 1801 bytes --] * Saphirus Sage (saphirus497@gmail.com) [12.03.09 00:53]: > I've been trying to setup my laptop to enter ACPI S3 (suspend to ram) > when I close the lid. I currently have the scripts setup as such: > /etc/acpi/events/lid > event=button[ /]lid.* > action=/etc/acpi/actions/lid.sh Looks normal. > /etc/acpi/actions/lid.sh > #!/bin/bash Maybe a sleep 1 will help with your issue (or more secs...) > for i in $(cat /proc/acpi/button/lid/LID/state | grep -o closed); do ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This only has elements when the lid is closed, so the do block will only be exexuted, if the lid is closed. > if [ $i = "closed" ]; then ^^^^^^^^^^^^^^^^^^^^^^^^^^ Therefor this is totally pointless, because we only come to this point if the lid is closed and thus $i is always == "closed" > /usr/sbin/pm-suspend > fi > if [ $i != "closed" ]; then > sleep 5 > fi This whole block will never ever be reached, so you can easily erase it. > done > 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? > You should test if your Desktop Environment does the suspending for you. Then you have to tweak there, to get the behaviour you want. HTH Sebastian -- " Religion ist das Opium des Volkes. " Karl Marx SEB@STI@N GÜNTHER mailto:samson@guenther-roetgen.de [-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-03-12 12:13 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-03-11 22:41 [gentoo-user] Bash and ACPI issue - laptop lid Saphirus Sage 2009-03-12 0:42 ` Mike Kazantsev 2009-03-12 1:35 ` Saphirus Sage 2009-03-12 12:13 ` Sebastian Günther
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox