aboutsummaryrefslogtreecommitdiffstats
path: root/.config/herbstluftwm/notify.sh
blob: 190d4961e217e3da97b525a2042572e25ee6a735 (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
#!/bin/bash

monitor_w=$1
window_p=$2
panel_h=$3

popup_w=$(echo "$monitor_w - (2 * $window_p)" | bc)
popup_h=$panel_h
popup_x=$window_p
popup_y=$window_p

popup_opts="-w $popup_w -h $popup_h -x $popup_x -y $popup_y"

while true; do

	bat_lvl=$(cat /sys/class/power_supply/BAT1/capacity)
    bat_stat=$(cat /sys/class/power_supply/BAT1/status)
    
    if [[ $bat_lvl -le 5 && $bat_stat == "Discharging" ]]; then
        $4 -m "Battery level critical: $bat_lvl%%" -u "high" $popup_opts
    elif [[ $bat_lvl -eq 10 && $bat_stat == "Discharging" ]]; then
        $4 -m "Battery level low: $bat_lvl%%" $popup_opts
    elif [[ $bat_lvl -eq 50 && $bat_stat == "Discharging" ]]; then
        $4 -m "Battery level at $bat_lvl%%" $popup_opts
    elif [[ $bat_lvl -eq 100 && $bat_stat == "Charging" ]]; then
        $4 -m "Battery fully charged"
    fi

    sleep 60;
done