feat: add external monitor detection

This commit is contained in:
ineanto 2025-05-14 11:31:33 +02:00
parent 8cd08998c1
commit 4524badf49
Signed by: ineanto
GPG key ID: E511F9CAA2F9CE84
2 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# v1.0 - Shell Script to automatically set display based on connected monitors.
get_active_monitors()
{
xrandr | awk '/ connected/ && /[[:digit:]]x[[:digit:]].*+/{print $1}'
}
monitors=$(get_active_monitors)
for sub in "${monitors[@]}"; do
if [[ *"$sub"* == *"HDMI-1"* ]]; then
echo "HDMI-1 detected, switching to one primary display."
xrandr --output eDP-1 --off --output HDMI-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal
fi
done