diff --git a/setup_screen_hypr.sh b/setup_screen_hypr.sh new file mode 100755 index 0000000..55c782d --- /dev/null +++ b/setup_screen_hypr.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -eu + +handle() { + case $1 in + monitoradded*) + disable_integrated_display_if_connected_to_external_monitors + ;; + monitorremoved*) + disable_integrated_display_if_connected_to_external_monitors + ;; + esac +} + +disable_integrated_display_if_connected_to_external_monitors() { + MONITORS=$(hyprctl monitors all -j | jq ".[] | {name: .name, mode: .availableModes[0]}") + NUMBER_OF_MONITORS=$(echo "$MONITORS" | grep -c "name") + if [ "$NUMBER_OF_MONITORS" -gt 1 ]; then + hyprctl keyword monitor eDP-1, disabled + else + hyprctl keyword monitor eDP-1, highres highrr, auto, 1 + fi + + pkill waybar || true + waybar +} + +disable_integrated_display_if_connected_to_external_monitors + +socat -U - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do handle "$line"; done