git: update smtpuser, set transfer.fsckObjects
[~bandali/configs] / .local / bin / battery-percentage-time
1 #!/bin/sh
2
3 dbus_send() {
4 label=$1
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}'
11 }
12
13 perc=$(dbus_send 'Percentage')
14 state=$(dbus_send 'State')
15
16 if [ "$state" -eq 2 ]; then # Discharging
17 secs=$(dbus_send 'TimeToEmpty')
18 elif [ "$state" -eq 1 ]; then # Charging
19 secs=$(dbus_send 'TimeToFull')
20 fi
21
22 printf '%s%%%%%2dh%02dm \n' "$perc" $((secs / 3600)) $((secs % 3600 / 60))