June 14, 2014 · bash debian dell hacks linux nvidia productivity screen twinview vga workflow xorg xrandr

A quick note on xrandr

I've been playing today with TwinView on my laptop as I have an unused, old-ish Dell screen lying around with no use (have been using it for initial setup of my home server) and decided to make use of it. I come across a post saying to add 'static' configuraion into xorg.conf file:

Section 'Device' 
Identifier 'Generic Video Card' 
Driver 'nvidia' 
Option 'ConnectedMonitor' 'DFP-0, CRT-0' 
Option 'UseDisplayDevice' 'DFP-0, CRT-0' 
Option 'UseEdidFreqs' 'false' 
Option 'UseEDID' 'true' 
Option 'TwinView' 'true' 
Option 'TwinViewOrientation' 'LeftOf' 
Option 'SecondMonitorHorizSync' '30-160' 
Option 'SecondMonitorVertRefresh' '30-85' 
Option 'MetaModes' 'DFP-0:1280x800,VGA-0:1024x768' 
Option 'TwinViewXineramaInfoOrder' 'DFP-0, VGA-0' ... 
EndSection

This setup worked like a charm, but"¦ there's always a but. Since this configuration would run on a laptop, it would be inconvenient to change the X configuration any time I didn't have additional screen with me. And since laptop is supposed to be mobile, this wouldn't be a perfect solution.

Then I remembered of  xrandr. It is a command-line tool to interact with the XRandR extension [see x.org], which allows for live (re)configuration of the X server without restarting it. It provides automatic discovery of modes (resolutions, refresh rates, etc.) together with the ability to configure outputs dynamically (resize, rotate, move, etc.).

The easiest thing to do was to create two simple shell scripts to hot plug/unplug additional display:

##Enable second screen 
#!/bin/bash 
xrandr --output VGA-0 --auto --right-of LVDS-0 & exit
##Disable second screen 
#!/bin/bash 
xrandr --output VGA-0 --off & exit

Not to forget to chmod +x them, and that's it!

One more thing I did was to add keyboard shortcuts into my Openbox configuration files to make my life easier:

<keybind key="W-S-o">
  <action name="Execute">
    <command>
      /bin/sh '/home/bubbl/bin/twin.sh'
    </command>
  </action>
</keybind>
<keybind key="W-s-p">
  <action name="Execute">
    <command>
      /bin/sh '/home/bubbl/bin/twin-off.sh'
    </command>
  </action>
</keybind>

and now I enjoy dynamic TwinView on my laptop.

IMG_20140614_103851

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket

Contact