Go Back   nV News Forums > Linux Support Forums > NVIDIA Linux

Newegg Daily Deals

Reply
 
Thread Tools
Old 10-16-09, 12:33 AM   #1
davidonlaptop
Registered User
 
Join Date: Oct 2009
Posts: 10
Default Laptop Docking : script to Change number of displays

Hi!

I use two types of ServerLayout : one display (only laptop) and two displays (laptop + external monitor) and I like to make a script that applies the settings without rebooting the x-server.

The nvidia-settings can do it (in TwinView mode) but how to ask it to do it from a script?
davidonlaptop is offline   Reply With Quote
Old 10-16-09, 01:59 AM   #2
packermann
Registered User
 
Join Date: Mar 2009
Posts: 47
Default Re: Laptop Docking : script to Change number of displays

You could use disper (see posts in this forum). For the automatic switching you will have to use udev and write some rules. This depends on your hardware, what kind of events are triggerd when you dock.
packermann is offline   Reply With Quote
Old 10-16-09, 09:41 AM   #3
davidonlaptop
Registered User
 
Join Date: Oct 2009
Posts: 10
Default Re: Laptop Docking : script to Change number of displays

Quote:
Originally Posted by packermann View Post
You could use disper (see posts in this forum). For the automatic switching you will have to use udev and write some rules. This depends on your hardware, what kind of events are triggerd when you dock.
Cool, I'll read on disper.

I am running Ubuntu 9.04 with a GeForce 8400M GS and a LG L204WT monitor. Where to look for the event? The videocard, the monitor the distro?
davidonlaptop is offline   Reply With Quote
Old 10-16-09, 09:42 AM   #4
davidonlaptop
Registered User
 
Join Date: Oct 2009
Posts: 10
Default Re: Laptop Docking : script to Change number of displays

I mean it's a not a real dock (ie: monitors, mouse, usb, etc.) are hooked up manually, is there still events generated in this case?
davidonlaptop is offline   Reply With Quote
Old 10-18-09, 09:41 AM   #5
packermann
Registered User
 
Join Date: Mar 2009
Posts: 47
Default Re: Laptop Docking : script to Change number of displays

You have to look yourself, if your machine generates some events. You could use udevadm for ths (http://linux.die.net/man/8/udevadm)
packermann is offline   Reply With Quote
Old 10-23-09, 01:07 AM   #6
davidonlaptop
Registered User
 
Join Date: Oct 2009
Posts: 10
Default Re: Laptop Docking : script to Change number of displays

Thanks I got disper working perfectly!

But can't figure out how to catch events for monitor hooking and unplugging.

I've follow this guide and tried :

Code:
sudo tail -f -n 0 /var/log/kern.log
sudo tail -f -n 0 /var/log/dmesg
sudo tail -f -n 0 /var/log/messages
sudo tail -f -n 0 /var/log/udev
I get absolutely no output for each of these commands, am I doing something wrong?

Here's the output of disper:
Code:
david@bangkok:~$ disper --list
display DFP-0: Seiko
 resolutions: 320x240, 400x300, 512x384, 576x432, 680x384, 640x480, 720x450, 640x512, 700x525, 800x512, 840x525, 800x600, 960x540, 1024x768, 1280x800
display CRT-0: LG L204WT
 resolutions: 320x240, 400x300, 512x384, 680x384, 640x480, 720x450, 700x525, 840x525, 800x600, 960x540, 832x624, 960x600, 1024x768, 1152x864, 1360x768, 1280x960, 1440x900, 1280x1024, 1400x1050, 1920x1080, 1680x1050
Any idea?
davidonlaptop is offline   Reply With Quote
Old 10-23-09, 02:55 AM   #7
packermann
Registered User
 
Join Date: Mar 2009
Posts: 47
Default Re: Laptop Docking : script to Change number of displays

Difficult to say. I'm not a udev-specialist and maybe your laptop isn't even generating any event when you are docking it into the station. I've bound disper to a key-combination, so I have to trigger it manualy.
packermann is offline   Reply With Quote
Old 10-25-09, 11:18 PM   #8
davidonlaptop
Registered User
 
Join Date: Oct 2009
Posts: 10
Default Re: Laptop Docking : script to Change number of displays

I wonder how can Window$ detect the second screen?

Oh well, how did you do your key combination, can you paste your config here?
davidonlaptop is offline   Reply With Quote

Old 10-26-09, 06:27 AM   #9
packermann
Registered User
 
Join Date: Mar 2009
Posts: 47
Default Re: Laptop Docking : script to Change number of displays

For getting Fn-F7 properply working on my thinkpad, I've followed http://www.thinkwiki.org/wiki/Sample_Fn-F7_script and afterwards I just bound disper in gnome-keybindings to this combination.
packermann is offline   Reply With Quote
Old 10-27-09, 06:46 PM   #10
davidonlaptop
Registered User
 
Join Date: Oct 2009
Posts: 10
Default Re: Laptop Docking : script to Change number of displays

Awesome!

Thanks packerman!
davidonlaptop is offline   Reply With Quote
Old 05-19-10, 03:30 PM   #11
davidonlaptop
Registered User
 
Join Date: Oct 2009
Posts: 10
Default Re: Laptop Docking : script to Change number of displays

Hey packerman, could you post your disper-modified version of the fn-f7 script ?

There seemed to be a lot of xrandr related stuff in there that doest not apply to disper.
davidonlaptop is offline   Reply With Quote
Old 05-20-10, 01:40 PM   #12
packermann
Registered User
 
Join Date: Mar 2009
Posts: 47
Default Re: Laptop Docking : script to Change number of displays

Nothing special, no need to hazzle with xrandr
Code:
#!/bin/bash
if [ $(disper -l | grep -c display) -eq "1" ]; then
        disper -s
else
        disper -e
fi
Save this to whatever you want, make it executable and bind it to a keycombination you like.
packermann is offline   Reply With Quote
Reply


Thread Tools

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
Forum Jump


All times are GMT -5. The time now is 01:16 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.