From db2290048eb86e24b34419b818eb20d2d9cc37ef Mon Sep 17 00:00:00 2001 From: Tim Wundenberg Date: Fri, 28 Nov 2025 22:01:37 +0100 Subject: [PATCH] feat: setup screen for hyprland --- setup_screen_hypr.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 setup_screen_hypr.sh 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