Sunday, 14 March 2010

Automatic Dual Screen with your laptop

Print E-mail
Developing - Servicios (Daemons)
Written by Mario Alberto Medina Nussbaum   
Wednesday, 01 October 2008 14:39

Have you ever connected a monitor to your laptop and fought to have the image display on the monitor? Or maybe make your desktop wanted to see widespread, but has been a headache, and finally hacks and hacks you've done to the xorg.conf, and has not been well at all. Well I have great news for you.

There are already methods to change resolution, extend the desktop horizontally or vertically and all with a few commands. That's why we developed this little PHP script that takes care of everything you need to self-adjust your monitor resolution to put to the right of your laptop and automatically, when connected to extend the desktop.

First things first, the list of requirements:

  • Linux more or less new, say with Xorg 1.4 or higher
  • The xrandr program (apt-get install xrandr in ubuntu or centos yum install xrandr in / fedora)
  • PHP CLI or CGI mode installed
  • Root privileges on your installation
  • A text editor such as joe, nano, pico, kate or similar

Once you turn to the list of requirements we will learn the steps.

The first thing to do is detect the resolution of your screen, this is to:

  xrandr 

it will look like this:

Screen 0: minimum 320 x 200, current 2560 x 1024, maximum 2720 x 1024

VGA-0 connected 1280x1024 +1280 +0 (normal left inverted right x axis and axis) 338mm x 270mm

1280x1024 60.0 * + 75.0 59.9

1152x864 74.8

1024x768 75.1 60.0

800x600 75.0 60.3

640x480 75.0 60.0

720x400 70.1

LVDS connected 1280x800 +0 +0 (normal left inverted right x axis and axis) 0mm x 0mm

1280x800 59.5 * + 60.0

1280x768 60.0

1024x768 60.0

800x600 60.3

640x480 59.9

S-video disconnected (normal left inverted right x axis and axis)

As you can realize, in the first line there is a "maximum 2720x1024, this is edited in the file / etc/X11/xorg.conf, find Section" Screen ", and that for the subsection" Display ", a Once I find him, edit or add this line:

Virtual 2720 1024 # <--- add this line must

The first parameter is the maximum horizontal resolution, say, I have two monitors, my laptop, external of 1280x800 and a 1280x1024 LCD. So 1280 +1280 = 2720 join now vertical, the highest volume since all this going to deploy horizontally. If you were to use the change to vertically, summary of high and would use the largest width to set these parameters.

This done, save and restart your graphical environment, you can do with rebooting the machine, or simply stop and restart the service in some distributions when you go to xdm / kdm / gdm (ie where asks login and password) you can press it e or control-alt-e and restarts the graphics.

Once you've done this, try again, and check if the maximum is what you wear, it is essential to the second step.

Now it's very simple, you just have to tell you which screen is primary and what secondary. I always use the internal laptop as primary, because if the power goes out you lose your primary (if you have no UPS).

xrandr - output LVDS - mode 1280x800

This instruction set my primary and LVDS display with a resolution of 1280x800, then goes high school:

xrandr - output VGA-0 - right-of LVDS - mode 1280x1024

List! already have manually made the change, and your desktop is extended. But now you must do this automatically. How? because with a script that runs these steps, detect when an external monitor attached, and then detects the highest resolution of the main screen and execute the commands by putting the proper display and proper way.

Then, running this script to start your graphical session and keeping it all the time, checking once a minute if there are changes of monitors can be connected or disconnected to automatic resizing.

To get the script, I invite you to the download section. Also I invite you to comment on this article in order to improve our quality of content.



Compartir este artículo
Reddit! Del.icio.us! Mixx! Free and Open Source Software News Google! Live! Facebook! StumbleUpon! TwitThis Joomla Free PHP
Comments
Add New Search RSS
+/-
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.
julio  - que bien |2009-03-15 14:36:46
avatar Jamas se me habia ocurrido esto de colocar un monitor a mi lapto es mjuy bueno
y super comodo que bien esxplicado y facil de comprender , gracias por
compartir sus conocimientos.
medisoft  - Actualizacion |SAdministrator |2009-08-19 21:42:36
avatar He de aclarar que con las nuevas versiones de Linux, en especial ubuntu/kubuntu
es todavia mas sencillo, en el menu de sistema -> display puedes escoger como
vas a mostrar en tu dual screen, y darle aplicar, y listo. La ventaja de este
script es que en cuanto conectas el monitor te cambia la resolución.

Otra nota es que para obtener resoluciones horizontales de mas de 2048 pixeles
es necesario tener una tarjeta de video muy nueva o tener DRI2 instalado, el
problema es que DRI2 a este momento es mas lento y bastante inestable, se traba
a cada rato sin razon, pero de que jala, lo hace.
Cristian  - Ummm |2009-08-31 23:20:08
avatar A mi me parece genial la idea... pero preferiría un script en bash, python o
perl... porque eso de tener que instalar PHP para un tipo de cosas como estas
como que no :P

Igual, muchas gracias por el tip. Un saludo!
medisoft |SAdministrator |2009-09-01 18:21:29
avatar bueno, la razon de hacerlo en PHP es por que me agrada el php y por que lo
conozco.

a fin de cuentas, perl tambien se tendría que instalar si no fuera por que hay
muchos scripts que lo utilizan, y python tambien se requiere instalar
 
You need to login or register to post comments.
Discuss this item on the forums. (0 posts)