아치(Arch)리눅스에서 lid close 를 acpid 통해서 처리. Linux+more

기본 컨셉은 다음과 같음.

#pacman -S acpi acpid
/etc/acpi/handler.sh 파일에 pm-suspend 추가
#nano /etc/acpi/handler.sh

case "$1"
button/lid)
pm-suspend
;;


상세한 내용은 다음과 같음.

acpid comes with a number of predefined actions for triggered events, such as what should happen when you press the Power button on your machine. By default, these actions are defined in /etc/acpi/handler.sh, which is executed after any ACPI events are detected (as determined by /etc/acpi/events/anything).
The following is a brief example of one such action. In this case, when the Sleep button is pressed, acpid runs the command echo -n mem >/sys/power/state which should place the computer into a sleep (suspend) state:
button/sleep)
case "$2" in
SLPB) echo -n mem >/sys/power/state ;;
*) logger "ACPI action undefined: $2" ;;
esac
;;

Unfortunately, not every computer labels ACPI events in the same way. For example, the Sleep button may be identified on one machine as SLPB and on another as SBTN.
To determine how your buttons or Fn shortcuts are recognized, run the following command from a terminal as root:
# tail -f /var/log/messages.log
Now press the Power button and/or Sleep button (e.g. Fn+Esc) on your machine. The result should look something this:
logger: ACPI action undefined: PBTN
logger: ACPI action undefined: SBTN
If that does not work, run:
# acpi_listen
Then press the power button and you will see something like this:
power/button PBTN 00000000 00000b31
The output of acpi_listen is sent to /etc/acpi/handler.sh as $1, $2 , $3 & $4 parameters. Example:
$1 power/button
$2 PBTN
$3 00000000
$4 00000b31

As you might have noticed, the Sleep button in the sample output is actually recognized as SBTN, rather than the SLPB label specified in the default /etc/acpi/handler.sh. In order for Sleep function to work properly on this machine, we would need to replace SLPB) with SBTN).
Using this information as a base, you can easily customize the /etc/acpi/handler.sh file to execute a variety of commands depending on which event is triggered.

reference: 

덧글

댓글 입력 영역