Signup/Sign In

Linux acpid - Advanced Configuration and Power Interface events Daemon

acpid is a daemon process, which starts at system boot and runs in the background, to notify programs for ACPI events. It opens an ACPI events file (/proc/acpi/event by default) and attempts to read lines which represent ACPI events. If the events file does not exist, acpid will attempt to connect to the Linux kernel via the input and netlink layers (Information is transferred between kernel and user-space processes using Netlink. It comprises an internal kernel API for kernel modules and a common sockets-based interface for user space programmes.). When an ACPI event is received from one of these sources, acpid will examine a list of rules, and execute the rules that match the event. acpid will ignore all incoming ACPI events if a lock file exists (/var/lock/acpid by default).

acpid looks for rules defined in the configuration directory and files (/etc/acpi/events by default). and parse all regular files with names that consist entirely of upper and lower case letters, digits, underscores, and hyphens that do not begin with a period (.) or end with a tilde (~).

Each file must define two things: an event and an action. Any blank lines, or lines where the first character is a hash ('#') are ignored. Extraneous lines are flagged as warnings. Each line has three tokens: the key, a literal equal sign, and the value. The key can be up to 63 characters, and is case-insensitive (but whitespace matters). The value can be up to 511 characters, and is case and whitespace sensitive.

In addition to rule files, acpid also accepts connections on a unix domain socket (/var/run/acpid.socket by default). Once an application is connected, acpid will send the text of all ACPI events to the client. The client has the responsibility of filtering for messages about which it cares. acpid will not close the client socket except in the case of a SIGHUP (with 1 signal number signal is used to indicate that a network or phone connection has been lost, possibly resulting in the user's terminal being disconnected.). acpid will log all of its activities, as well as the standard output (stdout) and standard error (stderr) of any actions, to syslog.

acpid command syntax:

acpid [options]

Acpid tool in Linux terminal

acpid command options:

-c, --confdir directory changes the directory in which acpid looks for rule configuration files. Default is /etc/acpi/events.
-C, --clientmax number changes the maximum number of non-root socket connections which can be made to the acpid socket. Default is 256.
-d, --debug increases the acpid debug level by one.
-e, --eventfile filename changes the event file from which acpid reads events. Default is /proc/acpi/event.
-n, --netlink forces acpid to use the Linux kernel input layer and netlink interface for ACPI events.
-f, --foreground keeps acpid in the foreground by not forking at startup, and makes it log to stderr (standard error) instead of syslog (system logs).
-l, --logevents tells acpid to log information about all events and actions.
-L, --lockfile filename changes the lock file used to stop event processing. Default is /var/lock/acpid.
-g, --socketgroup groupname changes the group ownership of the unix domain socket to which acpid publishes events.
-m, --socketmode mode changes the permissions of the unix domain socket to which acpid publishes events. Default is 0666.
-s, --socketfile filename changes the name of the unix domain socket which acpid opens. Default is /var/run/acpid.socket.
-S, --nosocket tells acpid not to open a unix domain socket. This overrides the -s option, and negates all other socket options.
-p, --pidfile filename tells acpid to use the specified file as its pidfile. If the file exists, it will be removed and over-written. Default is /var/run/acpid.pid.
-r, --dropaction action defines the pseudo-action which tells acpid to abort all processing of an event, including client notifications. Default is <drop>.
-t, --tpmutefix enables special handling of the mute button for certain Lenovo ThinkPad models with mute LEDs that get out of sync with the mute state when the mute button is held down.
-h, --help display this help and exit.
-v, --version output version information and exit.

Start ACPI daemon:

Before jumping to the examples, we should check if the status of acpid service as follows:

  • Using systemctl command (operates on the files in /etc/init.d):
    • Start the service with this command (requires root privileges): systemctl start acpid
    • Now you can check the status with this command: systemctl status acpid
  • Using service command (operates on the files in /lib/systemd) :
    • Start the service with this command (requires root privileges):service acpid start
    • Now you can check the status with this command: service acpid status
? acpid.service - ACPI event daemon
     Loaded: loaded (/lib/systemd/system/acpid.service; disabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-09-06 06:22:06 EDT; 13min ago
TriggeredBy: ? acpid.socket
             ? acpid.path
       Docs: man:acpid(8)
   Main PID: 645367 (acpid)
      Tasks: 1 (limit: 2840)
     Memory: 220.0K
        CPU: 58ms
     CGroup: /system.slice/acpid.service
             ??645367 /usr/sbin/acpid

Sep 06 06:22:06 kali systemd[1]: Started ACPI event daemon.
Sep 06 06:22:06 kali acpid[645367]: starting up with netlink and the input layer
Sep 06 06:22:06 kali acpid[645367]: 1 rule loaded
Sep 06 06:22:06 kali acpid[645367]: waiting for events: event logging is off

acpid command examples

1. Alter the location of the directory where acpid searches for rule configuration files. (It's /etc/acpi/events by default.)

$ acpid -c directory/path
$ acpid –confdir=directory/path


2. Adjust the number of non-root socket connections that the acpid socket can accept. (256 is the default.)

$ acpid -C number
$ acpid –clientmax=number


3. Increase acpid debug level by one.

$ acpid -d
$ acpid –debug


4. Alter the event file that acpid reads events from. It is /proc/acpi/event by default.

$ acpid -e file/path
$ acpid –eventfile=file/path


5. Compel acpid to utilize the netlink interface and input layer of the Linux kernel for ACPI events.

$ acpid -n
$ acpid –netlink


6. Keep acpid in the foreground by not forking at startup, and makes it log to standard error instead of system logs.

$ acpid -f
$ acpid –foreground


7. Instruct the acpid command to record details of all Events and Actions.

$ acpid -l
$ acpid –logevents

Running acpid command to log events in Linux terminal
8. The lock file that is used to halt event processing is modified. (/var/lock/acpid is the default.)

$ acpid -L file/path
$ acpid –lockfile=file/path


9. Change acpid's domain socket for publishing events' group ownership.

$ acpid -g groupname
$ acpid –socketgroup=groupname


10. Alter the unix domain socket's permissions so that acpid can publish events to it. (Standard is 0666.)

$ acpid -m mode
$ acpid –socketmode=mode


11. Change the name of the UNIX domain socket that acpid open. (/var/run/acpid.socket is the default.)

$ acpid -s file/path
$ acpid –socketfile filename


12. Prohibit opening of a UNIX domain socket by acpid . This cancels out all other socket options and supersedes the -s option.

$ acpid -S
$ acpid –nosocket


13. Specify the file that acpid should use as its pidfile. The file will be deleted and overwritten if it already exists. (/var/run/acpid.pid is the default.)

$ acpid -p file/path
$ acpid –pidfile=file/path


14. Define the pseudo-action that instructs acpid to stop handling any further events or client notifications. (<drop> is the default.)

$ acpid -r action
$ acpid –dropaction=action


15. Gives some Lenovo ThinkPad models with mute LEDs that become out of sync with the mute state when the mute button is depressed, and unique handling of the mute button.

$ acpid -t
$ acpid –tpmutefix

Conclusion

Linux acpid command is an important tool for managing power and system events on your Linux system. It is essential for proper power management and handling system events such as shutting down, suspending, and restarting the system. By using the commands discussed above, you can easily start, stop, and restart acpid on your Linux system.



About the author:
Pradeep has expertise in Linux, Go, Nginx, Apache, CyberSecurity, AppSec and various other technical areas. He has contributed to numerous publications and websites, providing his readers with insightful and informative content.