Files
puter-swaycfg/batterystatus.sh

15 lines
483 B
Bash
Executable File

#!/bin/sh
while true; do
BATTERY=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|to full|percentage" | awk -F': +' '
/state:/{s=$2}
/time to full:/{split($2,a,",");h=int(a[1])}
/percentage:/{gsub(",",".",$2);p=$2}
END{if(s=="charging") printf("%dh - %.2f%%\n",h,p)}
')
DATE=$(date +'%Y-%m-%d %X')
VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}')
echo "$VOLUME | $BATTERY | $DATE"
sleep 1
done