ACPI

ACPI (Advanced Configuration and Power Management Interface) is a power management system. It is part of the BIOS.

Kernel
You need to activate the following kernel options:

Software
Desktop environments react on the common events generated by ACPI. If you don't use a desktop environment or want to react on special events, install :

SELinux
If you want acpid to be able to shutdown the system, make sure you have installed and relabelled

Configuration
The scripts in define how to react on ACPI events. You can edit them or add more.

Boot service
You can now start acpid. If you are using openrc:

To start acpid at boot time, add it your default runlevel:

In case of systemd:

Advanced configuration
You may be satisfied with the default ACPI package set up. Although, you may need a little extra configuration to get acpid daemon treat some basic ACPI events like AC power plug in/out, multimedia keys etc.

You will have to edit along with  if necessary and why not a complicated set up that make use of  and. Just put your scripts and event files there.

A basic may be enough. The following is an example on what could be done.

Examples
ACPI events and actions examples for Lenovo ThinkPad T410