Laptop external display hotplugging

System Software

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

4
Score 70.0%
Description:

Hate having to switch to a second display or projector with your laptop?
Here's your solution. Install this package to your Ubuntu laptop and whenever you plug in an external monitor or projector, the laptop will change to using the projector instantly and automatically.


To install:
sudo add-apt-repository ppa:hughescih/ppa && sudo apt-get update && sudo apt-get install autoswitcher


Testing:
- Works on Ubuntu 10.04, 10.10, 11.04
- Tested on Nvidia graphics cards
- Should work just fine on Intel and ATI cards
Last changelog:

8 years ago

2.0.0 : New AppIndicator menu. Support for clone desktop, extend desktop. Remembers settings after reboot and applies them. Menu hides if no external display detected.

1.0.3 : After a reboot, it will switch back to the second monitor on startup if connected.

jjack92

8 years ago

Thank you very much for this very nice Indicator applet. It works perfectly on my HP 8540W running Ubuntu Natty and my external ACER screen.

Report

cewanf

8 years ago

Doesn't work for me on my Thinkpad T410 (intel graphics):

:~$ /usr/lib/autoswitcher/autoswitcher.py -v -d
Display Resolution Detected: 1440x900
Traceback (most recent call last):
File "/usr/lib/autoswitcher/autoswitcher.py", line 327, in <module>
autoModeSwitcher = ModeSwitchAutomator(menu, debug=options.verbose)
File "/usr/lib/autoswitcher/autoswitcher.py", line 99, in __init__
self.set_display_mode(self.mode, self.direction)
File "/usr/lib/autoswitcher/autoswitcher.py", line 172, in set_display_mode
self.sw.switch_clone(displays, resolution)
File "/usr/lib/autoswitcher/switcher/swxrandr.py", line 71, in switch_clone
ress = ResolutionSelection(res, displays)
File "/usr/lib/autoswitcher/switcher/resolutions.py", line 145, in __init__
self.set(sress, displays)
File "/usr/lib/autoswitcher/switcher/resolutions.py", line 165, in set
raise ValueError('unrecognised resolution selection')
ValueError: unrecognised resolution selection

Report

C

qb89dragon

8 years ago

I've updated it to try and correct the issue you're having. Give it a try when it becomes available in about 15 mins on the ppa.
Thanks!

Report

cewanf

8 years ago

Thanks for the quick reply! I now get a slightly different error:

:~$ /usr/lib/autoswitcher/autoswitcher.py -v -d
Display Resolution Detected: 1600x1200
Traceback (most recent call last):
File "/usr/lib/autoswitcher/autoswitcher.py", line 322, in <module>
autoModeSwitcher = ModeSwitchAutomator(menu, debug=options.verbose)
File "/usr/lib/autoswitcher/autoswitcher.py", line 99, in __init__
self.set_display_mode(self.mode, self.direction)
File "/usr/lib/autoswitcher/autoswitcher.py", line 174, in set_display_mode
self.sw.switch_clone(displays, resolution)
File "/usr/lib/autoswitcher/switcher/swxrandr.py", line 71, in switch_clone
ress = ResolutionSelection(res, displays)
File "/usr/lib/autoswitcher/switcher/resolutions.py", line 145, in __init__
self.set(sress, displays)
File "/usr/lib/autoswitcher/switcher/resolutions.py", line 165, in set
raise ValueError('unrecognised resolution selection')
ValueError: unrecognised resolution selection

Report

boamaod

8 years ago

Do you suppose it also works on Ubuntu 11.04?

Report

C

qb89dragon

8 years ago

Yes it's working fine for me on my macbook pro 5,5 running 11.04.

Report

luv2hike

8 years ago

This rocks! It works perfectly on my zareason laptop running mythbuntu 10.04. This saved me all kinds of time. Thanks for sharing it with us.

Report

C

qb89dragon

8 years ago

Thanks for the comment. I'm glad you like it. If you don't mind me asking, what GPU do you have. This is so I can add it to the list of ones known to work.

Report

luv2hike

8 years ago

Hi. It's a laptop with NVIDIA GeForce GT 330M.

I did just discover one issue, though. My screensaver no longer works when using it as a regular laptop if the autoswitcher daemon is running.

After the idle timeout period, it starts to dim the display as normal, but then instead of showing the ants screensaver in GNOME, it returns to the desktop at the original brightness. Any ideas?

Report

C

qb89dragon

8 years ago

I'm guessing it turns off the screen when it puts the display to sleep by 'unplugging' the main display internally.
You can confirm this for me though by running
/usr/lib/autoswitcher/autoswitcher.py -v -d
and letting it kick on the screensaver, and post the output from the terminal up here so I can see what it's up to.
Thanks!

Report

luv2hike

8 years ago

It didn't say much.

Initially Configured Displays set(['DFP-0'])
Resolution {'DFP-0': <switcher.resolutions.Resolution instance at 0x28fe050>}

Nothing more when the screensaver tried doing its thing. The daemon is still running though. Maybe I need to kill it first? What is the proper way to stop and start the daemon without a reboot?

Report

C

qb89dragon

8 years ago

The daemon runs at userlevel, not as a system service, therefore cannot write a pid file in the usual place - therefore it doesn't act like a normal daemon, more like pulseaudio or something like that.

Having more than one instance doesn't stop the detection parts from working however. But perhaps you could try and see if the issue persists after you have stopped the daemon.

Here's how to stop it:
ps -A -f | grep autoswitcher.py

and you have to look for something like this:

1000 1432 1 0 Mar02 ? 00:02:07 python /usr/lib/autoswitcher/autoswitcher.py

the number you're looking for here is 1432. So now you type in

kill 1432

and you won't have it running anymore.

To start it back up, run the following:
/usr/lib/autoswitcher/autoswitcher.py

Report

luv2hike

8 years ago

Ok, thanks. I killed the running daemon which was running as root so I used:

sudo pkill -f autoswitcher

Then I started it from the Terminal with -v -d and waited for the screen saver. Still the same thing: No other info except what I posted before from when it just starts up.

Report

wacmemphis

8 years ago

unfortunately it doesn't work for me... nothing changes when i plug in an external monitor.
i don't know how to debug it, since it starts new threads...
i'm using intel gma graphics chip.

Report

C

qb89dragon

8 years ago

I will update this with an option to not daemonize. Then you should be able to see a python traceback of whatever happened. It's based off of the disper libraries. Perhaps you could try using that and see if it works for you switching displays from the command line with it.

Report

C

qb89dragon

8 years ago

I've added the updates (via the ppa). You should be able to see what the problem is when running autoswitcher in a terminal as follows:

/usr/lib/autoswitcher/autoswitcher.py -v -d

Thanks for your help debugging this.

Report

wacmemphis

8 years ago

ok, using just the internal monitor i get:

Initially Configured Displays set(['LVDS1'])
Resolution {'LVDS1': <switcher.resolutions.Resolution instance at 0x8a2f38c>}

plugging the external display in, doesn't result in any change.

however restarting the autoswitcher when the external monitor is plugged in, i get:

Initially Configured Displays set(['LVDS1', 'VGA1'])
Resolution {'LVDS1': <switcher.resolutions.Resolution instance at 0x90b838c>, 'VGA1': <switcher.resolutions.Resolution instance at 0x90b86ec>}

so it extends the desktop to both screens. unplugging the external monitor doesn't switch back to just the internal monitor...

any ideas?

Report

C

qb89dragon

8 years ago

Hmm. It looks like you got no errors there and the detection is working fine if VGA1 shows up in that list. The displays should switch over completely not extend however.
To switch back the program waits for the display VGA1 to be removed from the list. I'll add a option (when I get back from work tonight) that shows the display polling results so you can see if VGA1 disappears from the list when you pull the plug on it.

Report

wacmemphis

8 years ago

did you update something? in the last days i had no time to check for updates. the latest version from the ppa does not show any events when i plug in a monitor...

Report

brainvision

8 years ago

I can't understand why people think that all the world is using ubuntu! those people are quite exactly like winzozz users!!
I'm starting to hate them, I'm sorry!! or better, a part of them..

Report

C

qb89dragon

8 years ago

Oh, you are concerned that I put 'Ubuntu' in the description.
I just happen to do so for some of the following reasons:
- It has only been tested on Ubuntu
- It has been built and packaged for Ubuntu (deb)
- It ties into Ubuntu features, such as libnotify which cannot be guaranteed present in other distros
- It is hosted on Launchpad and will be updated through that (Ubuntu/Debian/etc)
- Ubuntu is the most popular distro with the strongest focus on usability and seamless ease of use, which makes it an ideal target for this kind of technology.
- You can port this to most mainstream distributions with 'alien', or could just figure out that it is written in python and you can strip out the libnotify components and run it as a daemon on any distro, even on KDE.

Report

cwickert

8 years ago

I am not concerned there is Ubuntu in the description, I am concerned that all that is offered for download are Ubuntu packages and there is no link to the sourcecode.

I know it's written in python, still this or alien cannot replace a proper source tarball. Please be so kind to link it from this page. TIA!

Report

C

qb89dragon

8 years ago

Thanks for your interest in trying this on other distros.
A little known fact about deb packages is they're just renamed tar.gz files that can be opened with your archive manager to reveal, in this case, the original python source file. The install script in there might also be useful as it copies a .desktop file to /usr/share/gnome/autostart

Report

brainvision

8 years ago

I put Ubuntu in the description???

wtf are you saying??? the problem is that this is ONLY for ubuntu!,I don't care a cent of the description!

Report

gnumdk

8 years ago

Mouahaha!

If you want stuff about your favorite distro on this site, just contribute, it's free software, you can package, create themes, wallpapers...

Sure, it's easy to speak while doing nothing...

Report

8 years ago

2.0.0 : New AppIndicator menu. Support for clone desktop, extend desktop. Remembers settings after reboot and applies them. Menu hides if no external display detected.

1.0.3 : After a reboot, it will switch back to the second monitor on startup if connected.

12345678910
16
product-maker mixalns Jul 09 2011 9 excellent
product-maker xyzzymagicat Apr 12 2011 3 bad
product-maker figure002 Apr 08 2011 9 excellent
product-maker stribianese91 Feb 24 2011 9 excellent
product-maker jbus Feb 15 2011 9 excellent
product-maker freeazy Feb 15 2011 9 excellent
product-maker mikomi Feb 15 2011 9 excellent
product-maker Count: 4 Rating: 5.0
File (click to download) Version Description PackagetypeArchitectureRelease Channel Downloads Date Filesize DL OCS-Install MD5SUM
*Needs ocs-url or ocs-store to install things
Pling
Details
license
version
2.0.0
updated Jun 25 2011
added Feb 15 2011
downloads 24h
0
page views 24h 1
System Tags app software