LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-11-2013, 06:20 AM   #1
akamikeym
Member
 
Registered: May 2008
Posts: 112

Rep: Reputation: 21
Possible to switch monitor on pluging in of cable?


I've a netbook running mint which I would like to use with my TV via the netbook's VGA cable. The problem is that when I plug in the cable it extends my desktop by default which causes my limitted GPU to grind to a halt for quite a while.

It would be nice to be able to plug in the TV to my VGA and have linux switch my primary display to that monitor, turning off the internal monitor. Then restore to the internal when I unplug the cable.

I assume this is possible since it automatically extends my desktop at the moment. Does anyone have any ideas how to set this up?
 
Old 05-11-2013, 06:44 AM   #2
akamikeym
Member
 
Registered: May 2008
Posts: 112

Original Poster
Rep: Reputation: 21
OK, well I found a page that looks promising:

http://www.danilopianini.org/index.p...cles&Itemid=23

It uses udev to run a script on monitor plugging and unplugging that checks the setup and runs xrandr to switch monitors.

However somehow in the gnome displays settings which I was struggling with when I last had the TV plugged in I've apparently stumbled across the setting that does exactly what I want.

I tried plugging in the TV when monitoring udev as instructed in the linked page (above) but when I did so it did exactly what I wanted; it turned off the internal screen and switched the primary display to the TV, and when I unplugged it, it turned off the TV and switched back to the internal screen.

 
Old 05-11-2013, 02:52 PM   #3
akamikeym
Member
 
Registered: May 2008
Posts: 112

Original Poster
Rep: Reputation: 21
Hi,

Tried following the guide for another Netbook I have which I'm running openbox on and I decided I'd like the same behaviour for.

It didn't work off the bat; it initially refused to run my script and the script didn't do what I really wanted (i.e. only one monitor at a time, using the VGA one if connected over the internal one.)

/etc/udev/rules.d/80-vga.rules
Code:
ACTION=="change", SUBSYSTEM=="drm", RUN+="/etc/udev/scripts/hotplug.sh"
/etc/udev/scripts/hotplug.sh
Code:
#!/bin/bash - 
set -o nounset
read STATUS < /sys/class/drm/card0-VGA-1/status 
export DISPLAY=:0
export XAUTHORITY=/home/mikey/.Xauthority
if [ "$STATUS" = "connected" ]; then
  /usr/bin/xrandr --output LVDS1 --off --output VGA1 --auto --screen 0
else
  /usr/bin/xrandr --output VGA1 --off --output LVDS1 --auto --screen 0
fi
For some reason the HOTPLUG selection from the Udev rule in the linked page didn't work; I'm not sure what exactly it was doing, so I'm not sure now if it's being too selective and running for other events beyond the monitor being plugged and unplugged. Guess it wont do too much harm.

Last edited by akamikeym; 05-11-2013 at 02:54 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Laptop monitor shuts off when attempting to switch to external monitor (Debian) sgh Linux - Laptop and Netbook 4 02-20-2012 11:33 PM
Cable Modem + Static IP + Smoothwall Router + Switch = Horrible connection AustinMarton Linux - Networking 1 03-12-2008 04:50 PM
crossover cable or switch? acid_kewpie Linux - Networking 5 11-30-2006 07:05 PM
Fast DSL/Cable Router/Switch kuphryn General 8 05-25-2006 01:59 AM
Get usb.c: ignoring set_interface when pluging in a Belkin USB Direct Connect Cable qwerty102 Linux - Networking 0 02-15-2005 08:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration