Linux Dual Monitor Script

As some of you may know, I run am running Arch Linux on my Lenovo T420. Being a programmer, I often use a second monitor. It took me a little while to figure out how to get this auto-configured on boot in Arch, but I've come up with the following script.

This script will autodetect if you have a secondary monitor (in my case VGA1) connected to your laptop. And set it up your screens accordingly using xrandr.

To get it to run at boot, I simply include it in my .xinitrc file in my home directory.

Feel free to use the script, although you may have to change the screens accordingly.


  1. Are you using the VGA and display port on the laptop or do you have a port replicator? I want to use my port rep and it has a vga and dvi.


    1. I am using the VGA port on the side of my t420. I'm not sure how you would go about using a port replicator. I can research into that a little bit. My guess is that you would replace VGA with DVI. I will let you know if I find anything.