Updated dunst and added automatic monitor switching
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
@@ -1,38 +1,54 @@
|
||||
#!/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="";
|
||||
intern="eDP";
|
||||
extern="HDMI-A-0";
|
||||
|
||||
function kb_routine {
|
||||
oldKBD="$KBD";
|
||||
case "$(xset -q | grep -A 0 'LED' | cut -c59-67)" in
|
||||
"00000000")
|
||||
KBD="Europe" ;;
|
||||
"00001000")
|
||||
KBD="Deutsch" ;;
|
||||
*) KBD="unknown" ;;
|
||||
esac
|
||||
oldKBD="$KBD";
|
||||
case "$(xset -q | grep -A 0 'LED' | cut -c59-67)" in
|
||||
"00000000")
|
||||
KBD="Europe" ;;
|
||||
"00001000")
|
||||
KBD="Deutsch" ;;
|
||||
*) KBD="unknown" ;;
|
||||
esac
|
||||
|
||||
if [ "$KBD" != "$oldKBD" ]; then
|
||||
dunstify -r 1 "$KBD";
|
||||
fi
|
||||
if [ "$KBD" != "$oldKBD" ]; then
|
||||
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;
|
||||
fi
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
function monitor {
|
||||
oldmonstats="$monstats"
|
||||
if xrandr | grep "$extern disconnected"; then
|
||||
monstats="$intern"
|
||||
xrandr --output "$extern" --off --output "$intern" --auto
|
||||
else
|
||||
monstats="$extern"
|
||||
xrandr --output "$intern" --off --output "$extern" --auto
|
||||
fi
|
||||
|
||||
if [ "$oldmonstats" != "$monstats" ]; then
|
||||
dunstify -r 1 "Using $monstats.";
|
||||
fi
|
||||
}
|
||||
while :
|
||||
do
|
||||
kb_routine
|
||||
battery_routine
|
||||
sleep 1;
|
||||
kb_routine;
|
||||
battery_routine;
|
||||
monitor;
|
||||
sleep 1;
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user