* .config/mpv/mpv.conf: Add, containing the emacsconf-talks profile.
[~bandali/configs] / .local / bin / battery-percentage-time
1 #!/bin/sh
2 dbus_send() {
3 label=$1
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}'
10 }
11
12 perc=$(dbus_send 'Percentage')
13 state=$(dbus_send 'State')
14
15 if [ "$state" -eq 2 ]; then # Discharging
16 secs=$(dbus_send 'TimeToEmpty')
17 elif [ "$state" -eq 1 ]; then # Charging
18 secs=$(dbus_send 'TimeToFull')
19 fi
20
21 printf '%s%%%%%2dh%02dm \n' "$perc" $((secs / 3600)) $((secs % 3600 / 60))