
Laptop external display hotplugging
Source (link to git-repo or to original if based on someone elses unmodified work):
Available as/for:
Description: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
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.
Ratings & Comments
36 Comments
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.
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
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!
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
Do you suppose it also works on Ubuntu 11.04?
Yes it's working fine for me on my macbook pro 5,5 running 11.04.
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.
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.
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?
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!
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?
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
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.
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.
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.
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.
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?
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.
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...
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..
Care to elaborate on your point in complete and meaningful sentences?
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.
yes exactly.. but this is a place for linux lovers,not ubuntu users!
This is also a place where people post things that they build for the community at no cost. If someone brought cookies they baked themselves to a party, would you harass that person because they didn't make cookies in your favorite flavor? Just because someone didn't make it for 'whatever-you-use-distro' does not suddenly entitle you to troll this site and harass other developers trying to help others have a better experience. It's open source, if it's not right for you, take it, fix it, publish it yourself. I built this because it solves a problem I was having. I didn't have to put it up on this site. In case it was of use to someone out there, it is put up here and packaged it with an installer. If you don't like free software, don't download it! Nobody obliges me to make my software work for every single distribution known to man... lease of all yourself.
yes man you are right.. the problem in fact is not the single contribution, but all the big number of contributions ONLY for ubuntu: themes, wallpapers, icons etc. etc. A large part of them are branded ubuntu, the rest are packaged for it! you can understand that a non-ubuntu user coul start to think that something is wrong.. can't you?? but anyway I don't want to troll nothing and nobody, I can assure you! sorry if my post looked like it!!