PDA

View Full Version : [ubuntu] automatic rotation with xrandr?



akaIDIOT
April 5th, 2009, 01:50 PM
I'm the happy owner of a tilting Samsung monitor. Although rotating the output is not enabled by default i managed to enable by adding the option in xorg.conf. So far, so good...

When i tilt my screen, it (the screen itself) shows me a little icon with the current rotation. Since the screen is able to detect whether it has been rotated, is it possible to make ubuntu catch this 'event' and rotate the screen to the correct setting?

Also while xrandr -o <rotation> works fine on the command line, the screen resolution program in gnome only got the extra option 'upside down' by enabling xrandr (had only normal before that). Is there an easy way to add '90 degrees left' or something to that? Having a button for this will reduce my need to rotate the output automatically :)

My setup:
Samsung SyncMaster 2493HM (connected through DVI)
nVidia GeForce 9800GT

My Ubuntu:
8.10 x64
nVidia restricted driver v177
running default version of X with config generated by nVidia X Server Settings (apart from the added lines for xrandr) and Compiz

Thanks in advance for any help! :)

akaIDIOT
April 13th, 2009, 03:51 PM
Anyone? Anything at all?

Aubergines
April 13th, 2009, 04:03 PM
You got a copy of your xorg.conf?

akaIDIOT
April 22nd, 2009, 10:55 PM
Sadly, the message that someone replied to my question was directed to my junk folder. More sadly, my graphics card is currently in RMA and I'm now running on an old model. By reinstalling the driver my xorg.conf was regenerated and thus i cannot paste the config file i used while posting this thread.

By enabling RandRRotation again i get the same effect though, the xorg.conf now looks like this:


Section "Monitor"
Identifier "Configured Monitor"
EndSection

Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 24
Option "RandRRotation" "True"
EndSection

Section "Module"
Load "glx"
EndSection

Section "Device"
Identifier "Configured Video Device"
Driver "nvidia"
Option "NoLogo" "True"
Option "RandRRotation" "True"
EndSection

xrandr will now again rotate fine, but the Screen Resolution tool still only shows "Upside Down"...

akaIDIOT
April 26th, 2009, 06:32 PM
While not a real answer to my question, i wrote a simple bash script that toggles the rotation of the screen using xrandr. No rocket science and maybe not that neat, but it might be useful for anyone wanting roughly the same :)



#~/bin/bash

CURRENT=`xrandr -q | head -n 1`
WIDTH=`expr "$CURRENT" : '.*current \([0-9]\+\)'`
HEIGHT=`expr "$CURRENT" : '.*current [0-9]\+ x \([0-9]\+\)'`

if [ $WIDTH = 0 -o $HEIGHT = 0 ]; then
echo "values from xrandr not read correctly, exiting"
exit 1
fi

if [ $WIDTH -gt $HEIGHT ]; then
xrandr -o left
else
xrandr -o normal
fi

bDerrly
July 1st, 2009, 06:23 PM
...


#~/bin/bash


You probably want
#!/bin/bash at the top of your script.

lswb
July 1st, 2009, 06:37 PM
Try running this command in a terminal:


tail -F /var/log/syslog


It will show what is being recorded in your system log. Rotate the screen and see if any event is recorded noting the rotation. If is is, post the message here. As long as the system recognizes when the monitor is rotated it should be possible to write a udev rule or something similar that can act on it.

akaIDIOT
July 4th, 2009, 01:28 PM
Unfortunately nether the syslog nor xev listed anything happening when the screen detected rotation. What came to mind was the fact that my screen (Samsung 2394HM) comes in a variant that can act as a USB hub. Maybe the event would be transferred through that, though as i have the other version, i can't really test it...

lswb
July 4th, 2009, 02:53 PM
Unfortunately nether the syslog nor xev listed anything happening when the screen detected rotation.

Too bad. But mentioning USB made me think, maybe you can use something like this
http://www.sensr.com/products/civil-and-structural/gp2xl.php

if you can find something cheap enough.

akaIDIOT
July 5th, 2009, 01:52 PM
Too bad. But mentioning USB made me think, maybe you can use something like this
http://www.sensr.com/products/civil-and-structural/gp2xl.php

if you can find something cheap enough.

Hehe, the bash script serves me fine right now, but thanks for the suggestion :)

I guess I'll have to learn to live with this, no biggie. Thanks for all the help! :)

JKBurton
July 10th, 2009, 02:48 AM
Try this link: http://niels.kicks-***.org/index.php/2008/07/10/the-sound-of-the-dolphin-or-how-to-rotate-a-monitor/

The app he uses to detect the rotation is "ddccontrol", and is available thru the package manager.

( Okay, when you try loading the url above, it'll fail. In your address bar, replace the 3 asterisks with the letters a-s-s (no dashes), and that should fix it. Profanity filtering urls????