Comment 33 for bug 619897

Revision history for this message
Khar Tahk (khartahk) wrote :

If anyone is iterested I've got a shell script that I use to change display layout with a keyboard shortcut. I use Windows Key + F8 which is the same as my laptopts key to change the displays except that there it uses FN key. Any way this with windows key is much more usefull since i can sue a normal keyboard to change the displays. It changes from single to secondary to primary extend right and secondary extend left:

#! /bin/bash
DISPLAYS=$( disper -l | grep display | cut -f2 -d" " )

##
 # Get primary and if attached secondary display
 #
 # DISPLAY0=DSP-0, DISPLAY1=DSP-1
 ##
DISPLAY0=${DISPLAYS:0:5}
DISPLAY1=${DISPLAYS:7:5}

##
 # Get used displays
 #
 # FIRST=DSP-0 | DSP-1, SECND=DSP-1 | DSP-0
 ##
ALL=$(disper -p | grep metamode)
FIRST=$(echo $ALL | cut -f 1 -d "," | cut -f 2 -d ":")
FIRST=$(echo $FIRST | cut -f 1 -d" ")
SECND=$(echo $ALL | cut -f 2 -d "," | cut -f 1 -d ":")
SECND=$(echo $SECND | cut -f 1 -d" ")

XINERAMA=$(disper -p | grep xinerama | cut -f 2 -d ":")
XINERAMA=${XINERAMA:1}

DSPLY=$(echo $ALL | cut -f 2 -d "," | cut -f 5 -d " ")

if [ $DISPLAY0 ] && [ $DISPLAY1 ]
then
 if [ "$XINERAMA" == "$DISPLAY0, $DISPLAY1" ] && [ $FIRST == $DISPLAY0 ] && [ $SECND == $DISPLAY1 ]
  then
  disper -s -q > /dev/null
  #echo 1 PLUG0:"$DISPLAY0" PLUG1:"$DISPLAY1" FIRST:"$FIRST" SECND:"$SECND"
  #echo $XINERAMA
 elif [ "$XINERAMA" == "$DISPLAY1, $DISPLAY0" ] && [ $FIRST == $DISPLAY0 ] && [ $SECND == $DISPLAY1 ]
  then
  disper -q -e -d DFP-0,DFP-1 -t left > /dev/null && disper -e -d DFP-0,DFP-1 -t right > /dev/null
  #echo 2 PLUG0:"$DISPLAY0" PLUG1:"$DISPLAY1" FIRST:"$FIRST" SECND:"$SECND"
  #echo $XINERAMA
 elif [ $FIRST == $DISPLAY0 ] && [ $SECND != $DISPLAY1 ]
  then
  disper -q -S > /dev/null
  #echo 3 PLUG0:"$DISPLAY0" PLUG1:"$DISPLAY1" FIRST:"$FIRST" SECND:"$SECND"
  #echo $XINERAMA
 elif [ $FIRST == $DISPLAY1 ] && [ $SECND != $DISPLAY1 ]
  then
  disper -q -d $DISPLAY1,$DISPLAY0 -e -t left > /dev/null
  #echo 4 PLUG0:"$DISPLAY0" PLUG1:"$DISPLAY1" FIRST:"$FIRST" SECND:"$SECND"
  #echo $XINERAMA
 fi
else
 #echo 6 PLUG0: $DISPLAY0 PLUG1: $DISPLAY1 FIRST: $FIRST SECND: $SECND
 disper -q -s
fi