diff options
Diffstat (limited to '.config/herbstluftwm/notify.sh')
| -rwxr-xr-x | .config/herbstluftwm/notify.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/.config/herbstluftwm/notify.sh b/.config/herbstluftwm/notify.sh new file mode 100755 index 0000000..190d496 --- /dev/null +++ b/.config/herbstluftwm/notify.sh | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | monitor_w=$1 | ||
| 4 | window_p=$2 | ||
| 5 | panel_h=$3 | ||
| 6 | |||
| 7 | popup_w=$(echo "$monitor_w - (2 * $window_p)" | bc) | ||
| 8 | popup_h=$panel_h | ||
| 9 | popup_x=$window_p | ||
| 10 | popup_y=$window_p | ||
| 11 | |||
| 12 | popup_opts="-w $popup_w -h $popup_h -x $popup_x -y $popup_y" | ||
| 13 | |||
| 14 | while true; do | ||
| 15 | |||
| 16 | bat_lvl=$(cat /sys/class/power_supply/BAT1/capacity) | ||
| 17 | bat_stat=$(cat /sys/class/power_supply/BAT1/status) | ||
| 18 | |||
| 19 | if [[ $bat_lvl -le 5 && $bat_stat == "Discharging" ]]; then | ||
| 20 | $4 -m "Battery level critical: $bat_lvl%%" -u "high" $popup_opts | ||
| 21 | elif [[ $bat_lvl -eq 10 && $bat_stat == "Discharging" ]]; then | ||
| 22 | $4 -m "Battery level low: $bat_lvl%%" $popup_opts | ||
| 23 | elif [[ $bat_lvl -eq 50 && $bat_stat == "Discharging" ]]; then | ||
| 24 | $4 -m "Battery level at $bat_lvl%%" $popup_opts | ||
| 25 | elif [[ $bat_lvl -eq 100 && $bat_stat == "Charging" ]]; then | ||
| 26 | $4 -m "Battery fully charged" | ||
| 27 | fi | ||
| 28 | |||
| 29 | sleep 60; | ||
| 30 | done | ||
