Monday, September 24, 2007

Hotplugging a Secondary Display on Linux

GNU/Linux has been ready for the desktop for quite some time. And yet, when trying to tell the world about how ready Desktop Linux is, using a well prepared Open Office presentation, I am often faced with having to smile and say, oops looks like I need to restart X windows before my computer [Linux] can detect the LCD projector.

Lets face it, there are still some glitches here and there but the FOSS community is working hard at solving those problems, one by one. One such problem has been the inability to plug in an external display such as an external monitor or LCD projector and get it to "just work" without having to restart X Windows. That was until Xorg 7.3 came along!

Ever since I heard of Xorg 7.3 a couple of months earlier, I waited eagerly. Xorg 7.3 was finally released earlier this month. Unfortunately I was too busy to install it (i wanted to update other gentoo packages before I did this). Finally this weekend, I managed to upgrade my system (emerge -avuDN world) and get xorg 7.3 working!

Before I get to the monitor plugging, I'd like to make few comments on my experience doing this on Gentoo. First off, after emerging X org 7.3, X didn't start at all! Turned out that the upgrade process didn't recompile some dependency packages because their version hadn't changed. These are pretty much Gentoo specific issues and your not going to have to worry about it on binary based distros.

The other problem I had was with my synaptic touch pad not working. While trying to figure that out, I remembered that xorg 7.3 is supposed to have INPUT hotplugging and work even without an xorg.conf configuration file. So I renamed /etc/X11/xorg.conf and restarted zapped X (Ctrl+Alt+BS), and everything worked beautifully -- sort of. The synaptic touchpad worked and everything seemed fine, except I was having problems with compiz-fusion, the 3D stuff. I could get the 3D cube to rotate and see the wobbly effect but was unable to see what I was typing in the terminal. I could also not see any icons on certain windows such as of ccsm. It took me about an hour to figure out this was actually a problem with using an auto detected xorg.conf. So in the end, I reverted back to the old xorg.conf and found how to get synaptic working on it (thanks to google of course). Here is how my synaptic configuration on xorg.conf now looks like:


Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0

#InputDevice "TouchPad" "AlwaysCore" # Old setting
#InputDevice "Mouse0" "CorePointer" # Old setting
InputDevice "TouchPad" "CorePointer" # New for xorg 7.3
InputDevice "Mouse0" "SendCoreEvents"

InputDevice "Keyboard0" "CoreKeyboard"
Option "AIGLX" "true"
EndSection

Section "InputDevice"
Driver "synaptics"
Identifier "TouchPad"
Option "SendCoreEvents"
Option "Protocol" "auto-dev"
Option "SHMConfig" "on"
EndSection



Anyway, so now for the good stuff! I plugged in my 17" monitor to the VGA out of the notebook and waited. The signal not detected sign went away and the screen was pitch black. It was on indefinitely on standby. I zapped X again to restart it and this time got a display on the monitor. Hmmm not the hotplug I had in mind. A bit disappointed I wanted to get to the bottom of this - I mean hotplugging was supposed to be the main feature.

Turns out you can turn on a secondary display without restarting (zapping) X and here is how:

Meet the updated version of xrandr. You should have xrandr 1.2 for this to work.


# xrandr -v
Server reports RandR version 1.2


To get a list of displays available along with its status issue:

# xrandr -q
Screen 0: minimum 320 x 200, current 1280 x 800, maximum 2432 x 864
VGA connected (normal left inverted right x axis y axis)
1152x864 74.8
1024x768 84.9 75.1 70.1 60.0
832x624 74.6
800x600 99.7 84.9 72.2 75.0 60.3
640x480 99.8 84.6 75.0 72.8 60.0
720x400 70.1
640x350 70.1
LVDS connected 1280x800+0+0 (normal left inverted right x axis y axis) 331mm x 207mm
1280x800 60.0*+
1024x768 60.0
800x600 60.3
640x480 59.9
TV disconnected (normal left inverted right x axis y axis)


The output of xrandr -q shows two devices, VGA which represents my VGA out and is also shown to be connected to the monitor and LVDS, my LCD display. A third TV out is shown but is unfortunately not physically available on my notebook model :(

To enable my VGA out display and show an exact copy of whats on my LCD:

xrandr --output VGA --auto


This should automatically pick out the preferred resolution for the monitor and enable it. Alternatively if you want to specify the resolution from one of the modes supported (as given by xrandr -q):

xrandr --output VGA --mode 1024x768


You can turn off the external display by issuing

xrandr --output VGA --off


If you want you can create a VGA out toggle script and assign it to a keyboard short cut.

# vi ~/toggle-vga.sh
#!/bin/bash
XRANDR_OUT=`xrandr -q`
if echo "$XRANDR_OUT"|grep -q 'VGA connected'; then
echo 'Detected VGA connected';
if [ `echo "$XRANDR_OUT"|grep '*'|wc -l` -gt 1 ];then
echo 'Turning off VGA';
xrandr --output VGA --off
else
echo 'Turning on VGA';
xrandr --output VGA --auto
fi
else
echo 'No VGA connected!';
fi


Ok now for some fun stuff with xrandr! RandR was built to rotate the screen so lets try a rotation on the second screen:

# xrandr --output VGA --rotate left
# xrandr --output VGA --rotate right
# xrandr --output VGA --rotate normal


That last line will restore all rotations. Feeling dizzy? If not try these cool tricks:

# xrandr --output VGA --reflect x
# xrandr --output VGA --reflect y
# xrandr --output VGA --reflect xy
# xrandr --output VGA --reflect normal


Finally, wouldn't it be nice to extend your desktop to two displays. Well its now possible without having special dual head monitor settings in xorg.conf and even on an intel card! (with two vga outs of course).

There is a catch - you need to predefine the maximum combined resolution so that X server will pre-allocate that memory. Currently on intel cards, this means not enough memory for AIGLX/Compiz /3D. So I recommend creating a separate xorg.conf file for this purpose.

# vi /etc/xorg.conf
Section "Screen"
Identifier "Screen0"
Monitor "Monitor0"
Device "Card0"
DefaultDepth 24

SubSection "Display"
Viewport 0 0
Depth 24
Virtual 2432 864
EndSubSection
EndSection


# xrandr --output VGA --left-of LVDS

xrandr dual head
Depending on your monitor being to the left, right, above or below of your LCD screen you should use the proper option (see man xrandr).

Thats it for now.

Wednesday, September 19, 2007

SFD 2007 was HUGE & Hot!

SFD 2007
Software Freedom Day concluded on the 15th with several events happening around Sri Lanka and the world ofcourse.

The Excel World event, which I helped organize, turned out pretty well. It could ofcourse, have been a lot better if not for the matches that kept people @ home. But hey, who's complaining? Not me!

We had a lot of fun setting up the place. No one was in any particular hurry and we took our time. I got up about 8:30am or so and took another hour to get ready. Then grabbed a bunch of stuff like power strips, wireless dongles, power cords, mice, keyboard -- basically what ever I could lay my eyes on, and stuffed it in a luggage bag. I also picked up my desktop, my x-monitor (now dad's), and the mac mini (which I forgot to take) and headed off to TLC to pick up the APITT guys.

By the time we got to Excel it was close to 11AM. We then went to APITT to pick up rest of the stuff and it was probably around 12PM we actually started to set the place up. But help was on the way, as more friends showed up. The rest as they say it was history. The event went well in to the night and finished just minutes away from midnight.

Ofcourse, I am leaving out some of the drama we had to face @ Excel World, except to say it all worked out for the better in the end and that freedom shouldn't be taken for granted - "Even on SFD, you still have to fight for your Freedom, to have an event the way you want to have it". If some of you might remember we had a really bad experience last year.

me putting on the organizer hat:
All in all I felt that this year's SFD was bigger and a lot better as a whole. This couldn't have been possible if not for the FOSS community that came in at the right time and (magically) made things happen!

Special thanks to all the sponsors, Hardware Partner Digital House (Pvt) for giving out good looking machines that traveled around the country, Suntel for sponsoring the WiFi (with upgraded bandwidth mind you!) and doing too many radio spots in soo many channels :). Other thanks go out to ICTA for encouraging and supporting us, Excel World for a gr8 venue and support, APITT for giving us storage to store all the items and anyone else I might have forgotten because I drank too much coffee. Yes I'm sure it was coffee!

Enjoy the pics


Anyone other pics I'm missing? Leave a comment with link and I'll add it.

Friday, September 14, 2007

Come celebrate Software Freedom Day tomorrow @ Excel World

sfd07-logo-sml
Just came home after dropping off some items at APITT, which is a convenient storage location due to proximity, for tomorrow's SFD event at Excel World. As usual, the venue got finalized at the last minute (last minute being this evening)!

Tomorrow should be a busy day as nothing has been setup as yet. I am planning to head towards Excel in the morning along with the APITT LUGers to set the place up.I'm planning to bring a couple of my machines at home, like my recently dissected Mac Mini, or even perhaps my first notebook, the Sony Vaio which can only be used as disk less think client, which I showed off yesterday, at the SLIIT SFD event.

This is the 4th SFD event being held since its inception and this year seems to have the most events being organized around the country. Here are some of the local SFD events that are, or have been organized.

Anyway I'll blog more about the event tomorrow, live from the Excel World.

Not sure if you should attend? May be this will help...

Software Freedom Day is an international day dedicated to educating, advocating and celerating Free & Open Source Software (aka FOSS). Several countries are including Sri Lanka are having public events to celebrate the occation.

If you wanted to participate in a FOSS Community event then this is your chance. Couple of us geeks will be hanging out at Excel World through out Saturday from 10AM onwards.

We hope to show off some cool Free & Open Source applications, play video games on GNU/Linux and show you how you can too! and have an Install Fest where we will help you install GNU/Linux on your computer. Thats right!, bring your PC (no need monitor) or Notebook and get Linux installed for free! There will also be free Wi-Fi access thanks to Suntel so you constantly be connected!

We'll also have some cool geek merchandise like Tuxes, T shirts and
Linux distros.

See you all tomorrow!