feat(hypr): add event monitor for laptop lid

This commit is contained in:
Price Hiller 2023-08-20 17:28:54 -05:00
parent edc0e06777
commit 84c4b12b9b
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -30,5 +30,23 @@ monitor-ssid() {
done
}
monitor-laptop-lid() {
local laptop_lid_state
while :; do
laptop_lid_state="$(</proc/acpi/button/lid/LID0/state)"
laptop_lid_state="${laptop_lid_state##* }"
laptop_lid_state="${laptop_lid_state^^}"
case "${laptop_lid_state}" in
"CLOSED")
if hyprctl monitors -j | jq -er '.[] | select(.name=="eDP-1") | .name' >/dev/null; then
hyprctl keyword monitor "eDP-1, disable" >/dev/null && printf "Disabled laptop screen as the laptop was shut\n"
fi
;;
esac
sleep 1
done
}
monitor-ssid &
monitor-laptop-lid &
wait