2020-05-22 01:55:37 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-03-03 18:26:11 +01:00
|
|
|
lower_battery_threshold=10
|
2024-10-30 16:39:51 +01:00
|
|
|
KBD=""
|
|
|
|
oldKBD=""
|
|
|
|
connected_monitors=""
|
|
|
|
old_connected_monitors=""
|
|
|
|
internal_monitor="eDP"
|
2020-03-03 18:26:11 +01:00
|
|
|
|
2024-10-30 16:39:51 +01:00
|
|
|
kb_routine() {
|
|
|
|
oldKBD="$KBD"
|
2024-03-22 13:26:13 +01:00
|
|
|
case "$(xset -q | grep -A 0 'LED' | cut -c59-67)" in
|
2024-10-30 16:39:51 +01:00
|
|
|
"00000000")
|
|
|
|
KBD="Europe"
|
|
|
|
;;
|
|
|
|
"00001000")
|
|
|
|
KBD="Deutsch"
|
|
|
|
;;
|
|
|
|
*) KBD="unknown" ;;
|
2024-03-22 13:26:13 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
if [ "$KBD" != "$oldKBD" ]; then
|
2024-10-30 16:39:51 +01:00
|
|
|
dunstify -r 1 "$KBD"
|
2024-03-22 13:26:13 +01:00
|
|
|
fi
|
2019-10-29 13:56:54 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-10-30 16:39:51 +01:00
|
|
|
battery_routine() {
|
|
|
|
capacity="$(cat /sys/class/power_supply/BAT0/capacity)"
|
|
|
|
if [ "$capacity" -lt $lower_battery_threshold ]; then
|
|
|
|
acpi | grep -q '0: Discharging' && dunstify "Battery at $capacity%"
|
|
|
|
sleep 60
|
2024-03-22 13:26:13 +01:00
|
|
|
fi
|
2019-10-29 13:56:54 +01:00
|
|
|
}
|
|
|
|
|
2024-10-30 16:39:51 +01:00
|
|
|
monitors() {
|
|
|
|
connected_monitors=$(xrandr | grep -c "\<connected\>")
|
|
|
|
if [ "$connected_monitors" != "old_connected_monitors" ]; then
|
|
|
|
if [ "$connected_monitors" -eq 1 ]; then
|
|
|
|
# dunstify -r 1 "Swichting to single monitor"
|
|
|
|
xrandr --output $internal_monitor --auto
|
|
|
|
fi
|
|
|
|
if [ "$connected_monitors" -gt 1 ]; then
|
|
|
|
external_monitor=$(xrandr | grep "\<connected\>" | grep -v $internal_monitor | cut -d" " -f1)
|
|
|
|
# dunstify -r 1 "Swichting to external monitor"
|
|
|
|
xrandr --output $internal_monitor --off --output "$external_monitor" --auto
|
|
|
|
fi
|
|
|
|
old_connected_monitors=$connected_monitors
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
while :; do
|
|
|
|
kb_routine
|
|
|
|
battery_routine
|
|
|
|
# monitors
|
|
|
|
sleep 1
|
2019-08-14 22:05:24 +02:00
|
|
|
done
|