I would install the acpid package first. That will create two directories called /etc/acpi/events and /etc/acpi/actions.
Put a file called lidconf in /etc/acpi/events with these contents:
Code:
# run a script on lid open/close events
event=button/lid
action=/etc/acpi/actions/lid.sh "%e"
Now save your script as /etc/acpi/action/lid.sh. The script will receive an argument which will end with "open" or "close" (depending on whether, you guessed it, the lid was opened or closed), so you can test to see which case it is by starting the script with something like:
Code:
state=$(echo "$1" | cut -d " " -f 3)
case "$state" in
open)
# do what needs to be done when the lid is opened
;;
close)
# do what needs to be done when the lid is closed
;;
*)
# panic: not a state I know about!
esac
Once it is configured, you need to enable and start the acpi daemon with
Code:
systemctl enable acpid && systemctl start acpid
Hope that gets you started.