Skip to content

Instantly share code, notes, and snippets.

@natanaeljr
Created December 31, 2020 17:51
Show Gist options
  • Save natanaeljr/e751a35a399e6a8c1b13ec6bc8cfbdc2 to your computer and use it in GitHub Desktop.
Save natanaeljr/e751a35a399e6a8c1b13ec6bc8cfbdc2 to your computer and use it in GitHub Desktop.
Automatic configuration of monitors for my vostro laptop + other monitors - Put this in /etc/X11/xinit/xinitrc.d
#!/bin/sh
# array of connected monitors
monitors=( $(xrandr | grep ' connected ' | cut -d' ' -f1) )
# for the integrated display, set a higher resolution
if [ ${#monitors[@]} -eq 1 ]; then
xrandr --output $monitors --mode 1366x768 --panning 1920x1080 --scale 1.41
# for multiple monitors, enable them all
elif [ ${#monitors[@]} -gt 1 ]; then
last="${monitors[0]}"
configs="--output $last --auto --primary"
for monitor in ${monitors[@]:1}; do
configs="$configs --output $monitor --auto --right-of $last"
last="$monitor"
done
xrandr ${configs[@]}
unset last
unset configs
fi
unset monitors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment