aboutsummaryrefslogtreecommitdiff
path: root/Scripts/.local/scripts/status/battery
blob: 2a173017ce0a8e8f27f769a6ebf638e723a69c87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
capacity=$(cat /sys/class/power_supply/BAT0/capacity) || break
status=$(cat /sys/class/power_supply/BAT0/status)
time_left=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep "time to empty" | sed 's/.*://' | xargs echo $1)

if [[ $status == "Charging" ]]
then
    status=""
else
    if [[ $capacity -ge 75 ]]
    then
        status=""
    elif [[ $capacity -ge 50 ]]
    then
        status=""
    elif [[ $capacity -ge 25 ]]
    then
        status=""
    elif [[ $capacity -ge 10 ]]
    then
        status=""
    else
        status=""
    fi
fi
echo "$status $capacity% $time_left"