LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

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 powernon-zero - Running on battery or unable to determine

INSTALL

sudo apt install systemd
copy
sudo dnf install systemd
copy
sudo pacman -S systemd
copy
sudo zypper install systemd
copy
brew install systemd
copy
nix profile install nixpkgs#systemd
copy

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)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid