Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   How to send a function when the laptop Lid is closed ?(acpi) (http://www.linux-archive.org/debian-user/15649-how-send-function-when-laptop-lid-closed-acpi.html)

Jabka Atu 12-09-2007 10:36 AM

How to send a function when the laptop Lid is closed ?(acpi)
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,..


There is special file in /proc/acpi that changed it state when the lid
is closed :

/proc/acpi/button/lid/LID (on my acer 5102wlmi).


so if i close the lid it will :

(lid open) cat /proc/acpi/button/lid/LID/state
state: open
(lid closed) cat /proc/acpi/button/lid/LID/state
state: closed

I would like to do a spesific event when it happen (start a timer then
hibernate-disk).


the question is how ?


i tried creating the next file in /etc/acpi/event :


/etc/acpi/events# cat ./lid
event=button[/]lid
action=touch /tmp/lidfilename


Debian testing

- --
- --
Could you at least use man ?
Jabka Atu (aka mha13/Mashrom Head) || bsh83.blogspot.com
- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIVAwUBR1vTUm9p6JnF9I1qAQIxqA//Qk7Br4rVaEFw6LDLpqbnDqUsjPFHDYYU
WlBISCjxfjCo+AEouN7VIpdcFpRTRYb25j4Vehvsq9x3cyucE2 E3fuWXKlUCi0uH
f29cHpG7tpqWrlHvocePod2jgMWwo0nc0Y5TtbzjlI7coWxdz+ SQZbgMVQqDT7NE
cLfCTT8Fvl6y+ZPvA5MsJtZg/LYnT5mj3I04JQgXyHtewrhec55lSmUh8hrUoIsu
VPQvVDfQc/55pbiFEUHpUiym8ANnCBnY/id4WrBjh5YEB5iBqmKVAyqKWmKyOl3b
z4mGvpZHjQTSmCrfY6RNJfeY7ngSvHU8X/GFAQjT0F+qNTC7yvRpAMTLdyuTI0BS
+4RzV9F1a/jo9KaH/25EEMBxpgqQ18N7+gYClIIuTy97wXhoHKrE0a2kwNGNuLr6
//9bhmQurx/rBw5LWHzHNaet1sKeQF9Flar3HqWxm9BDKYAij+bPN2lpAiqkO P/l
car9ztzeX9ysc+KAONZ8ZJIcFLiavLyod7N435XFpre1Wwx7yv sRL0KFb9qoKx7q
M4e0527OaXZotsHg1RyElhKtV1he2vBId+HrlenpgopUMtVsIL ty4EEp4E7KzB1f
txXJy6g0EHdWpESYQqIYiFQnADkGjy0v+YYKO53P7xirnquiN0 JR+zCyLpsLeCXC
PPi9rAjYOCs=
=rt3m
-----END PGP SIGNATURE-----


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

"Michael Marsh" 12-09-2007 04:53 PM

How to send a function when the laptop Lid is closed ?(acpi)
 
This probably should have gone to debian-laptop, rather than
debian-user. However...

On Dec 9, 2007 6:36 AM, Jabka Atu <mashrom.head@gmail.com> wrote:
> i tried creating the next file in /etc/acpi/event :
> /etc/acpi/events# cat ./lid
> event=button[/]lid
> action=touch /tmp/lidfilename

I have the following as /etc/acpi/sleep_button:
event=button/sleep
action=/etc/acpi/sleep.sh

The sleep.sh script is then:
---[ begin sleep.sh ]---
#!/bin/sh

# if launched through a lid event and lid is open, do nothing
echo "$1" | grep "button/lid" && grep -q open
/proc/acpi/button/lid/LID/state && exit 0

# remove USB 1.1 driver
rmmod uhci_hcd

# sync filesystem and clock
sync
/sbin/hwclock --systohc

# switch to console
FGCONSOLE=`fgconsole`
chvt 6
#/usr/sbin/radeontool light off

# go to sleep
sleep 5 && echo -n "mem" > /sys/power/state

# readjust the clock (it might be off a bit after suspend)
/sbin/hwclock --adjust
/sbin/hwclock --hctosys

# reload USB 1.1 driver
modprobe uhci_hcd

# turn on the backlight and switch back to X
#radeontool light on
chvt $FGCONSOLE

# get alsa to actually play sound again -- very hackish
/usr/bin/amixer set Master toggle; /usr/bin/amixer set Master toggle
/usr/bin/amixer set PCM toggle; /usr/bin/amixer set PCM toggle
---[ end sleep.sh ]---

I cribbed this from somewhere (I can't recall where), with the amixer
tweaks at the end because my sound appears to always be disabled when
the laptop wakes up. It's not toggled to the "off" setting, though,
which is why I toggle Master and PCM twice each.

--
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
http://mamarsh.blogspot.com
http://36pints.blogspot.com


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


All times are GMT. The time now is 07:33 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.