Report whether the computer is connected to an external power…
Report whether the computer is connected to an external power source. More information: https://www.freedesktop.org/software/systemd/man/systemd-ac-power.html.
systemd-ac-power
yes
or no
to stdout
:systemd-ac-power --verbose