Saturday, June 28, 2014

Multiple displays with xrandr

Do you have a LCD TV or a spare monitor ? You can use that extra screen size  to see more code  : ) or watch a movie.  It's easy to manage multiple displays in linux using xrandr. Install xrandr if you havent already . I use a trivial script to switch between my displays . Here it is :


 #!/bin/bash
# switch from VGA to LVDS ( xrandr )
#####################################

# set wall to the path of your wallpaper
frm=$1
wall="/full/path/wallpaper.jpg"

if [[ $frm -eq 1 ]]
then
        xrandr --output VGA1 --auto
        sleep 2
        xrandr --output LVDS1 --off
        fbsetbg $wall  
else
        xrandr --output VGA1 --off
        sleep 1
        xrandr --output LVDS1 --auto
        fbsetbg $wall
fi



use xrandr --query  to check which displays have been detected and change the names of the displays accordingly. Also , If you are using fluxbox then make sure that  it's compiled with xinerama support. It helps with the window geometries etc. when switching.  Use a keybinding in fluxbox to switch from  VGA (tv) and LVDS ( laptop) so that if there is a power cut , you wont have a switched off laptop screen ! .

No comments:

Post a Comment

Post a Comment