aboutsummaryrefslogtreecommitdiff
path: root/Scripts/.local/scripts/status/battery
blob: 133a153ab8ea59f600514ac8d0f9212ee536f5e0 (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
27
28
29
30
#!/usr/bin/env bash
capacity=$(cat /sys/class/power_supply/BAT0/capacity) || break
time_left=$($HOME/.local/scripts/status/battery_time_left);
status=$(cat /sys/class/power_supply/BAT0/status)

if [[ $status == "Charging" ]]
then
    echo " $capacity% $time_left"
elif [[ $status == "Not charging" ]]
then
    echo " $capacity%"
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
        notify-send -u critical "Charge now!"
        status=""
    fi
    echo "$status $capacity% $time_left"
fi