2020-05-22 01:55:37 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
type xset >/dev/null 2>&1 || { echo >&2 "I require xset but it's not installed. Aborting."; exit 1; }
|
2019-10-29 13:56:54 +01:00
|
|
|
|
2020-03-03 18:26:11 +01:00
|
|
|
lower_battery_threshold=10
|
|
|
|
KBD="";
|
|
|
|
oldKBD="";
|
|
|
|
|
2019-10-29 13:56:54 +01:00
|
|
|
function kb_routine {
|
2019-08-14 22:05:24 +02:00
|
|
|
oldKBD="$KBD";
|
|
|
|
case "$(xset -q | grep -A 0 'LED' | cut -c59-67)" in
|
|
|
|
"00000000")
|
|
|
|
KBD="English (US)" ;;
|
|
|
|
"00001000")
|
|
|
|
KBD="Deutsch" ;;
|
|
|
|
*) KBD="unknown" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ "$KBD" != "$oldKBD" ]; then
|
2020-05-22 01:55:37 +02:00
|
|
|
dunstify -r 1 "$KBD";
|
2019-08-14 22:05:24 +02:00
|
|
|
fi
|
2019-10-29 13:56:54 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function battery_routine {
|
|
|
|
capacity=$(< /sys/class/power_supply/BAT0/capacity)
|
2020-03-03 18:26:11 +01:00
|
|
|
if [[ $capacity -lt lower_battery_threshold ]]; then
|
2021-03-02 12:23:16 +01:00
|
|
|
acpi | grep -q '0: Discharging' && dunstify "Battery at $capacity%";
|
2019-10-29 13:56:54 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
while :
|
|
|
|
do
|
2021-03-02 12:23:16 +01:00
|
|
|
# kb_routine
|
2019-10-29 13:56:54 +01:00
|
|
|
battery_routine
|
2019-08-14 22:05:24 +02:00
|
|
|
sleep 1;
|
|
|
|
done
|