72 lines
1.7 KiB
Bash
Executable File
72 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Enable, disable, toggle, or recover the internal laptop display
|
|
# omarchy:args=<on|off|toggle|recover>
|
|
|
|
TOGGLE="internal-monitor-disable"
|
|
TOGGLE_FLAG="$HOME/.local/state/omarchy/toggles/hypr/$TOGGLE.lua"
|
|
MIRROR_TOGGLE="internal-monitor-mirror"
|
|
|
|
# Get internal monitor name dynamically, including disabled outputs.
|
|
INTERNAL=$(hyprctl monitors all -j | jq -r '.[] | select(.name | contains("eDP")).name' | head -n 1)
|
|
|
|
wake() {
|
|
hyprctl dispatch 'hl.dsp.dpms({ action = "enable" })' >/dev/null 2>&1 || true
|
|
}
|
|
|
|
on() {
|
|
if omarchy-hyprland-toggle-enabled $TOGGLE; then
|
|
omarchy-hyprland-toggle $TOGGLE off
|
|
omarchy-notification-send -g "Laptop display enabled"
|
|
fi
|
|
|
|
wake
|
|
}
|
|
|
|
off() {
|
|
if [[ -z $INTERNAL ]]; then
|
|
omarchy-notification-send -g "No laptop display found"
|
|
exit 1
|
|
fi
|
|
|
|
if ! omarchy-hyprland-monitor-external-active; then
|
|
omarchy-notification-send -g "Can't disable the only active display"
|
|
exit 1
|
|
fi
|
|
|
|
if omarchy-hyprland-toggle-disabled $TOGGLE && omarchy-hyprland-toggle-disabled $MIRROR_TOGGLE; then
|
|
printf 'hl.monitor({ output = "%s", disabled = true })\n' "$INTERNAL" >"$TOGGLE_FLAG"
|
|
omarchy-notification-send -g "Laptop display disabled"
|
|
hyprctl reload
|
|
fi
|
|
}
|
|
|
|
recover() {
|
|
if ! omarchy-hyprland-monitor-external-active; then
|
|
if omarchy-hyprland-toggle-enabled $TOGGLE; then
|
|
omarchy-hyprland-toggle $TOGGLE off
|
|
fi
|
|
|
|
wake
|
|
fi
|
|
}
|
|
|
|
toggle() {
|
|
if omarchy-hyprland-toggle-enabled $TOGGLE; then
|
|
on
|
|
else
|
|
off
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
on) on ;;
|
|
off) off ;;
|
|
toggle) toggle ;;
|
|
recover) recover ;;
|
|
*)
|
|
echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|