Detecting when charging and discharging
#3
Code:
if [ `qdbus-qt5 --system org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.OnBattery` == true ] ; then
  echo on battery
else
  echo plugged in
fi

You can also use dbus-send (with a slightly less user-friendly API), or scrape the upower --dump output.
  Reply


Messages In This Thread
RE: Detecting when charging and discharging - by Kevin Kofler - 12-05-2023, 10:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  USB C to USB C charging not working. acidmilk 10 1,342 08-23-2024, 04:50 AM
Last Post: 67man
  /dev and etcher not detecting pinephone for writing pineuser0 2 2,940 09-13-2021, 03:10 PM
Last Post: pineuser0

Forum Jump:


Users browsing this thread: 5 Guest(s)