X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=upower%2Fupower-bat-refresh;fp=upower%2Fupower-bat-refresh;h=c92b53c2202cc3133308c09d86e41f1a2c26dedb;hb=b65a9ad8ed7a20111564281573d746709158e41e;hp=0000000000000000000000000000000000000000;hpb=b3eb33c68802db67fcc78437c96fb14d105fa308;p=shutils.git diff --git a/upower/upower-bat-refresh b/upower/upower-bat-refresh new file mode 100755 index 0000000..c92b53c --- /dev/null +++ b/upower/upower-bat-refresh @@ -0,0 +1,50 @@ +#!/bin/sh + +usage() +{ +cat << EOF +Usage: + $0 [OPTIONS] + $0 -h + +Refresh battery information provided by upower. + +OPTIONS: + -h Show this help. + -r Restart upower service +EOF +} + + +restartdaemon=0 + +while getopts "rRhnq8HSxc:s:t:T:uL" OPTION +do + case $OPTION in + h) + usage + exit + ;; + r) + restartdaemon=1 + ;; + *) + usage >&2 + exit 1 + ;; + esac +done +shift $(($OPTIND - 1)) + + + +if [ "${restartdaemon}" -gt 0 ]; then + systemctl restart upower +else + for bat in BAT0 BAT1; do + busctl call --system \ + org.freedesktop.UPower \ + /org/freedesktop/UPower/devices/battery_${bat} \ + org.freedesktop.UPower.Device Refresh + done +fi