18 lines
495 B
Bash
18 lines
495 B
Bash
#!/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
|
|
|
|
|