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