Display Switching Script

This is my script for detecting if an external monitor is plugged in, and, if so, making it primary. Add this to your startup applications and your desktop will automatically configure itself after you log in.

#!/bin/sh

chdmi=xrandr | grep "HDMI1 connected"
if [ -n $chdmi ] ;
then xrandr --output HDMI1 --primary ;
else
xrandr --auto
fi

Note that you can simply change HDMI1 to VGA1 or DVI1, according to what port you use for your external monitor.

About these ads

Follow

Get every new post delivered to your Inbox.