APMD(8)
π apmd β the Advanced Power Management monitor daemon
okay so bestie, welcome to APMD(8), an i386 System Manager's Manual page, and honestly? it's giving "the little daemon that could." sit down, grab a strawberry drink π, and let's get into it.
β¨ SYNOPSIS β¨
apmd [-d] [-f -file] [-s] [-v]
(ok yes, -f -file is literally what it says in the source, we don't fix that, we just report it π
)
π¦ DESCRIPTION π¦
So apmd is this utility that monitors when the specified Advanced Power Management (APM) events happen, and if one of those events occurs, it runs the whole sequence of commands that corresponds to that event. Only the events you actually specify in the config file get notified to apmd β everything else is ignored, like, completely. π
For each event posted by the APM BIOS, apmd invokes the sequence of commands specified in the configuration file. And here's the part that matters: when apmd is running with monitoring suspend/standby requests, the kernel will not process those requests. So if you want anything to actually happen when those events fire, you gotta explicitly configure the appropriate commands or built-in functions in the config file. no cap, that's on you.
The apmd utility recognizes the following runtime options:
-dβ starts in debug mode, which makesapmdexecute in the foreground instead of in daemon mode.-ffile β specifies a different configuration file file to be used in place of the default/etc/apmd.conf.-sβ causesapmdto simulate aPOWERSTATECHANGEevent when a power state change is detected (AC_POWER_STATE) but the bios of the laptop doesn't report it. This is the one that lets you do things like dimming the LCD backlight when you unplug the power cord. iconic behavior honestly β¨-vβ verbose mode.
When apmd starts, it reads the configuration file (/etc/apmd.conf as default) and notifies the set of events to be monitored to the APM device driver. When it terminates, the APM device driver automatically cancels monitored events. clean exit, no loose ends, we love that π
If the apmd process receives a SIGHUP, it will reread its configuration file and notify the APM device driver of any changes to its configuration. glow-up on demand fr fr.
The apmd utility uses the device /dev/apmctl to issue ioctl(2) requests for monitoring events and for controlling the APM system. This device file is opened exclusively, so only a single apmd process can be running at any time. one at a time, bestie, it's a monogamous device π
When apmd receives an APM event, it forks a child process to execute the commands specified in the configuration file and then continues listening for more events. The child process executes the commands specified, one at a time and in the order that they are listed. order matters, always.
While apmd is processing the command list for SUSPEND/STANDBY requests, the APM kernel device driver issues notifications to APM BIOS once per second so that the BIOS knows that there are still some commands pending, and that it should not complete the request just yet. it's basically going "hold on hold on hold on" every second π
The apmd utility creates the file /var/run/apmd.pid, and stores its process id there. This can be used to kill or reconfigure apmd. handy!
πΈ CONFIGURATION FILE πΈ
The structure of the apmd configuration file is quite simple. For example:
apm_event SUSPENDREQ {
exec "sync && sync && sync";
exec "sleep 1";
exec "zzz";
}
will cause apmd to receive the APM event βSUSPENDREQβ (which may be posted by an LCD close), run the βsyncβ command 3 times and wait for a while, then execute zzz (apm -z) to put the system in the suspend state. three syncs, one nap, one zzz. the full self-care routine π§
π The apm_event keyword
βapm_eventβ is the keyword which indicates the start of configuration for each event.
π APM events
If you wish to execute the same commands for different events, the event names should be delimited by a comma. The following are valid event names:
- Events ignored by the kernel if
apmdis running:
STANDBYREQ
USERSTANDBYREQ
SUSPENDREQ should include sync in the command list,
USERSUSPENDREQ should include sync in the command list,
BATTERYLOW only zzz should be specified in the
command list.
- Events passed to
apmdafter kernel handling:
NORMRESUME
CRITRESUME
STANDBYRESUME
POWERSTATECHANGE
UPDATETIME
CAPABILITIESCHANGE
Other events will not be sent to apmd. so don't come crying to apmd about them, it literally never heard of them π
π command line syntax
In the example above, the three lines beginning with βexecβ are commands for the event. Each line should be terminated with a semicolon. The command list for the event should be enclosed by β{β and β}β.
The apmd utility uses /bin/sh for double-quotation enclosed command execution, just as with system(3). Each command is executed in order until the end of the list is reached or a command finishes with a non-zero status code. The apmd utility will report any failed command's status code via syslog(3) and will then reject the request event posted by the APM BIOS. so like, a bad command literally vetoes the whole vibe check. no pressure π₯
π Built-in functions
You can also specify apmd built-in functions instead of command lines. A built-in function name should be terminated with a semicolon, just as with a command line. The following built-in functions are currently supported:
rejectβ reject last request posted by APM BIOS. This can be used to reject a SUSPEND request when the LCD is closed and put the system in a STANDBY state instead. the ultimate "no β€οΈ" move.
π FILES π
/etc/apmd.conf
/dev/apmctl
/var/run/apmd.pid
β EXAMPLES β
Sample configuration commands include:
apm_event SUSPENDREQ {
exec "/etc/rc.suspend apm suspend";
}
apm_event USERSUSPENDREQ {
exec "sync && sync && sync";
exec "sleep 1";
exec "apm -z";
}
apm_event NORMRESUME {
exec "/etc/rc.resume apm suspend";
}
apm_event STANDBYRESUME {
exec "/etc/rc.resume apm standby";
}
# resume event configuration for serial mouse users by
# reinitializing a moused(8) connected to a serial port.
#
#apm_event NORMRESUME {
# exec "kill -HUP `cat /var/run/moused.pid`";
#}
#
# suspend request event configuration for ATA HDD users:
# execute standby instead of suspend.
#
#apm_event SUSPENDREQ {
# reject;
# exec "sync && sync && sync";
# exec "sleep 1";
# exec "apm -Z";
#}
(yes, those commented-out blocks are in the original, and yes, the `cat /var/run/moused.pid` backticks are real β we keep everything character for character, that's the whole point π«Ά)
π SEE ALSO π
π HISTORY π
The apmd utility appeared in FreeBSD 3.3. vintage! a true elder of the apm cinematic universe.
π AUTHORS π
- Mitsuru IWASAKI
<iwasaki@FreeBSD.org> - KOIE Hidetaka
<koie@suri.co.jp>
Some contributions made by Warner Losh <imp@FreeBSD.org>, Hiroshi Yamashita <bluemoon@msj.biglobe.ne.jp>, Yoshihiko SARUMARU <mistral@imasy.or.jp>, Norihiro Kumagai <kuma@nk.rim.or.jp>, NAKAGAWA Yoshihisa <nakagawa@jp.FreeBSD.org>, and Nick Hilliard <nick@foobar.org>.
the whole squad showed up for this one, we stan a collaborative effort πΈπ
and that's the page, bestie! this Debian build is dated June 28, 1999 β yes, the same year the vibe was invented. slay forever, apmd. πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1999 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
- Copyright (c) 1999 KOIE Hidetaka <koie@suri.co.jp>
- Copyright (c) 1999 Yoshihiko SARUMARU <mistral@imasy.or.jp>
- Copyright (c) 1999 Norihiro Kumagai <kuma@nk.rim.or.jp>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms