How to change the primary monitor in Ubuntu or other Linux distributions

(1 vote, average 5.00 out of 5)

Using dual or multiple monitors in Linux is relatively straightforward as most monitors are automatically detected on the major distributions. However, Gnome does not give an option for specifying which monitor is the primary - that is to say the monitor which holds the panels by default and is considered the 'default' display. Fortunately, the xrandr utility can easily switch which monitor is the primary. Copy and paste the following script into a text file called monitor-switcher.sh.

Monitor Switcher Script
1
2
3
4
5
6
7
8
9
10
#!/bin/bash
# Author: Andrew Martin
# Credit: http://ubuntuforums.org/showthread.php?t=1309247
echo "Enter the primary display from the following:"			# prompt for the display
xrandr --prop | grep "[^dis]connected" | cut --delimiter=" " -f1	# query connected monitors
 
read choice								# read the users's choice of monitor
 
xrandr --output $choice --primary					# set the primary monitor
 

Once saved, make it executable by typing chmod +x monitor-switcher.sh into the terminal. Then, run it by typing ./monitor-switcher.sh. The script will then display a list of all detected monitors - type in the displayed name of the monitor you wish to make primary and hit enter. The script will then change the primary monitor immediately. Below is a sample run of the script:

 

$ ./monitor-switcher.sh
Enter the primary display from the following:
VGA1
LVDS1
VGA1

 

 

Partner Links:
Last Updated on Thursday, 30 September 2010 15:00  
Related Articles

» How to Make Fonts on Ubuntu Linux Look Crisp Like on Microsoft Windows

Have you noticed that fonts on Linux distributions (like Ubuntu) appear fuzzy compared to Microsoft Windows? This is because Ubuntu is using a font display technique called "hinting" which draws the fonts more accurately but can appear blurry to users used to Windows. Below is an example of the difference between Polished Fonts (the Ubuntu default) and Sharp Fonts (the Windows default):Thanks to for the screenshot.InstallationIt is possible to make Ubuntu (and other Linux distributions) render...

» How to Integrate Hulu Desktop with Windows 7 Media Center

If you would like to integrate Hulu Desktop with Windows 7 Media Center on your home theater PC, follow these few easy steps below: Hulu Desktop.Install Hulu Desktop. Hulu Desktop Integration.Install Hulu Desktop Integration by running the .msi file.That's it! You're finished. To access Hulu Desktop within Windows 7 Media Center, scroll down past Extras to see you'll find the Hulu Icon.Note: This integration will minimize Media Center and open Hulu Desktop when opened. When Hulu Desktop is...

» Redirect all output in shell script to a file

Redirecting a single command in a script to a file is straight-forward using the > syntax. For example, to redirect all STDERR output:1echo "hello, world" 2>> /tmp/filename.logTo redirect all lines of a Bash script to a file, add a scope around all of the lines and then redirect the scope to a file. For example:123456(echo "this is line 1 of my script"cat /proc/cpuinfodmesgecho "this is the end of my script") 2>> /tmp/filename.logThis allows you to capture all output of a script...