Files
dotfiles/hypr/scripts/lid.sh

41 lines
649 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ACTION="${1:-}" # "on" oder "off"
LAPTOP="eDP-1"
LAPTOP_MODE="2256x1504"
LAPTOP_SCALE="1.175"
has_external() {
hyprctl monitors | awk '/^Monitor /{print $2}' | grep -vq "^${LAPTOP}$"
}
enable_laptop() {
hyprctl keyword monitor "${LAPTOP}, ${LAPTOP_MODE}, 0x0, ${LAPTOP_SCALE}"
hyprctl dispatch dpms on "${LAPTOP}" 2>/dev/null || true
}
disable_laptop() {
hyprctl keyword monitor "${LAPTOP}, disable"
}
case "$ACTION" in
off)
if has_external; then
disable_laptop
else
disable_laptop
hyprlock
fi
;;
on)
enable_laptop
;;
*)
echo "usage: $0 {on|off}" >&2
exit 2
;;
esac