@@ -1,36 +1,57 @@
|
||||
#!/bin/sh
|
||||
|
||||
lower_battery_threshold=10
|
||||
KBD="";
|
||||
oldKBD="";
|
||||
KBD=""
|
||||
oldKBD=""
|
||||
connected_monitors=""
|
||||
old_connected_monitors=""
|
||||
internal_monitor="eDP"
|
||||
|
||||
function kb_routine {
|
||||
oldKBD="$KBD";
|
||||
kb_routine() {
|
||||
oldKBD="$KBD"
|
||||
case "$(xset -q | grep -A 0 'LED' | cut -c59-67)" in
|
||||
"00000000")
|
||||
KBD="Europe" ;;
|
||||
"00001000")
|
||||
KBD="Deutsch" ;;
|
||||
*) KBD="unknown" ;;
|
||||
"00000000")
|
||||
KBD="Europe"
|
||||
;;
|
||||
"00001000")
|
||||
KBD="Deutsch"
|
||||
;;
|
||||
*) KBD="unknown" ;;
|
||||
esac
|
||||
|
||||
if [ "$KBD" != "$oldKBD" ]; then
|
||||
dunstify -r 1 "$KBD";
|
||||
dunstify -r 1 "$KBD"
|
||||
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;
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
||||
while :
|
||||
do
|
||||
kb_routine;
|
||||
battery_routine;
|
||||
sleep 1;
|
||||
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
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user