dotfiles/config/.scripts/startup.sh

39 lines
784 B
Bash
Raw Normal View History

#!/bin/sh
type xset >/dev/null 2>&1 || { echo >&2 "I require xset but it's not installed. Aborting."; exit 1; }
lower_battery_threshold=10
KBD="";
oldKBD="";
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")
2021-05-29 21:46:59 +02:00
KBD="Europe" ;;
2019-08-14 22:05:24 +02:00
"00001000")
KBD="Deutsch" ;;
*) KBD="unknown" ;;
esac
if [ "$KBD" != "$oldKBD" ]; then
dunstify -r 1 "$KBD";
2019-08-14 22:05:24 +02:00
fi
}
function battery_routine {
capacity=$(< /sys/class/power_supply/BAT0/capacity)
if [[ $capacity -lt lower_battery_threshold ]]; then
acpi | grep -q '0: Discharging' && dunstify "Battery at $capacity%";
sleep 60;
fi
}
while :
do
2021-05-29 21:46:59 +02:00
kb_routine
battery_routine
2019-08-14 22:05:24 +02:00
sleep 1;
done