4 dbus-send
--print-reply=literal
--system \
5 --dest=org.freedesktop.UPower \
6 /org
/freedesktop
/UPower
/devices
/battery_BAT0 \
7 org.freedesktop.DBus.Properties.Get \
8 string
:org.freedesktop.UPower.Device \
9 string
:"${label}" |
awk '{print $3}'
12 perc
=$
(dbus_send
'Percentage')
13 state
=$
(dbus_send
'State')
15 if [ "$state" -eq 2 ]; then # Discharging
16 secs
=$
(dbus_send
'TimeToEmpty')
17 elif [ "$state" -eq 1 ]; then # Charging
18 secs
=$
(dbus_send
'TimeToFull')
21 printf '%s%%%%%2dh%02dm \n' "$perc" $
((secs
/ 3600)) $
((secs
% 3600 / 60))