LinuxCommandLibrary

systemd-ac-power

Check AC power connection status

TLDR

Check AC power status

$ systemd-ac-power
copy
Check with verbose output
$ systemd-ac-power -v
copy

SYNOPSIS

systemd-ac-power [OPTIONS]

DESCRIPTION

systemd-ac-power reports whether the computer is connected to an external power source (AC mains). It returns exit code 0 when on AC power and non-zero when on battery.
This is useful in scripts and systemd unit conditions to change behavior based on power state.

PARAMETERS

-v, --verbose

Print "yes" or "no" to stdout in addition to exit code
-h, --help
Display help

EXIT STATUS

0 - Running on AC power
non-zero - Running on battery or unable to determine

CAVEATS

Requires proper power supply detection by the kernel. Some desktop systems without batteries always report AC power. Virtual machines may report power state incorrectly.

HISTORY

systemd-ac-power provides a simple, scriptable interface to power supply status, enabling power-aware behavior in systemd units and shell scripts.

SEE ALSO

systemctl(1), upower(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community