From d9d9c28ed02611bdb2e37039fb62a19fc39815ad Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Sun, 5 Oct 2014 21:41:33 +0200 Subject: Added notifications --- .config/herbstluftwm/notify.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 .config/herbstluftwm/notify.sh (limited to '.config/herbstluftwm/notify.sh') 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 @@ +#!/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 -- cgit v1.2.3