*

Welcome, Guest. Please login or register.

Get your own OLPC - Buy an XO laptop on eBay!
Pages: [1]
Print
Author Topic: Mapping screen rotate button in fluxbox (and other window managers)  (Read 3647 times)

Mapping screen rotate button in fluxbox (and other window managers)

scrub
Commenter

Posts: 19


February 03, 2008, 11:15:11 PM

The xrandr command, which allows you to rotate the screen, doesn't seem to have any command line options which automatically rotate 90 degrees at a time.  So I wrote a script to check the current status of the screen rotation and rotate 90 degrees from there, so that I could bind the "rotate screen" button to do the same thing it does under sugar.  While I was at it, I set up a script to rotate in the opposite direction, so that you don't have to push the rotate button three times to rotate 270 degrees clockwise if you just want to rotate 90 degrees counter-clockwise.

Script to rotate clockwise, which I put in /usr/bin/xrandr_rotate.sh

current=`xrandr | grep connected | awk '{print $4}'`
if [ $current == "(normal" ]; then val=1
  elif [ $current == "left" ]; then val=2
  elif [ $current == "inverted" ]; then val=3
  elif [ $current == "right" ]; then val=0
fi

xrandr -o $val


Script to rotate counter-clockwise, which I put in /usr/bin/xrandr_reverse.sh

current=`xrandr | grep connected | awk '{print $4}'`
if [ $current == "(normal" ]; then val=3
  elif [ $current == "left" ]; then val=0
  elif [ $current == "inverted" ]; then val=1
  elif [ $current == "right" ]; then val=2
fi

xrandr -o $val

Make sure you make both those files executable:

su - root
chmod 755 /usr/bin/xrandr_rotate.sh
chmod 755 /usr/bin/xrandr_reverse.sh



For fluxbox, I added these key bindings in my /home/olpc/.fluxbox/keys file, to press the rotate button for clockwise rotations, or shift plus rotate button for counter clockwise rotations:

235 :ExecCommand xrandr_rotate.sh
Shift 235 :ExecCommand xrandr_reverse.sh


Under xfce or other window managers, you'll have to figure out the appropriate way to bind keys, and figure out what value the rotate button has.  But the idea will be the same.

I hope some of you find that useful; I've found this forum and the other OLPC info-spots around the web very very helpful as I've customized this thing for myself!

Scrub
Logged

#1 Re: Mapping screen rotate button in fluxbox (and other window managers)

mbanji
Commenter

Posts: 12


February 04, 2008, 01:30:01 AM

Hey, Scrub!

thanks for the good advice Smiley
i found this very helpful, will try it myself, cause i think this is
the best "achieve-my-goals-as-soon-as-possible" solution that i've found  Smiley

cheers! Smiley
Logged

#2 Re: Mapping screen rotate button in fluxbox (and other window managers)

eeksock
Contributor
*
Posts: 31


February 04, 2008, 05:46:48 PM

Scrub, thanks for this!  It works great!
Logged
Pages: [1]
Print
Jump to:  

Members
Total Members: 2406
Latest: sembik
Stats
Total Posts: 31943
Total Topics: 3843
Online Today: 25
Online Ever: 238
(April 18, 2011, 09:48:50 PM)
Users Online
Users: 0
Guests: 20
Total: 20