Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
X Screen Rotation via ACPI?
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
tomatopi
Tux's lil' helper
Tux's lil' helper


Joined: 18 Sep 2005
Posts: 130
Location: Ottawa

PostPosted: Sat Sep 09, 2006 2:04 pm    Post subject: X Screen Rotation via ACPI? Reply with quote

I've got an IBM X41 Tablet I'm putting Gentoo on. Everything seems to work quite well so far with a couple patches. Screen rotation works using a couple commands, which is great.
Code:
xrandr -o normal
xsetwacom set stylus rotate 0

This tablet actually sends an ACPI Hotkey event when the screen is rotated into tablet or laptop position. I've got acpid to try and run those rotation commands to automatically rotate the screen, but it doesn't work. I a "Cannot open display" error. I would guess those commands are being run as acpid user and it can't connect to the logged on user's X Session for the rotation to actually work.

Any ideas how to get this type of thing to work?
Back to top
View user's profile Send private message
truc
Advocate
Advocate


Joined: 25 Jul 2005
Posts: 3199

PostPosted: Sat Sep 09, 2006 11:30 pm    Post subject: Reply with quote

As you can see here we were looking for a way to make the rotation automaticly.

It looks like you found what we need: using ACPI!

I'd really like to know how you listen to ACPI events? how you did that and so on..:?:

well, if there really is a ACPI user, you could use 'sudo'

ie:

ACPI event --> command: sudo -u xsessionUser DISPLAY=":0" xrandr -o normal

:?:

(with the needed line in the sudoers file..)
_________________
The End of the Internet!


Last edited by truc on Sat Sep 09, 2006 11:33 pm; edited 1 time in total
Back to top
View user's profile Send private message
Big Jim Slade
Apprentice
Apprentice


Joined: 04 May 2005
Posts: 197
Location: Washington State

PostPosted: Sat Sep 09, 2006 11:31 pm    Post subject: Reply with quote

First, this is not an answer...

But, I've got a tablet too, and I'm wondering how you detected the screen ACPI event? I tried tailing /var/log/acpid but got nothing. Got nothing for the lid switch either, but I know it works, so there must be something else. I've got several tablet buttons too--one for rotation--but they don't seem to do anything. No response in xev or /var/log/acpid. Any ideas of how to see if they are sending anything anywhere, and how to capture it?

There ought to be some sort of tablet forum or something for this sort of thing.
Back to top
View user's profile Send private message
tomatopi
Tux's lil' helper
Tux's lil' helper


Joined: 18 Sep 2005
Posts: 130
Location: Ottawa

PostPosted: Sun Sep 10, 2006 2:39 pm    Post subject: Reply with quote

Thanks for the idea of sudo. I was debating it and wasn't sure how to do it, but I think I've got it. Here's how I did the ACPI for the X41 Tablet.

First you need the ibm_acpi module which is in the kernel under ACPI -> IBM ThinkPad Laptop Extras. Compile as a module.

By default, the "hotkeys" are disabled so create /etc/modules.d/ibm_acpi:
Code:
options ibm_acpi hotkey=enable


Make sure you have acpid installed.

Visit /etc/acpi/events and create two files. Name them whatever you want, but I used ibm_swivel_up and ibm_swivel_down
Code:

# /etc/acpi/events/ibm_swivel_up
# called when put into laptop mode
event = ibm/hotkey HKEY 00000080 0000500a
actions=/etc/acpi/ibm_lid.sh laptop

and
Code:

# /etc/acpi/events/ibm_swivel_down
# called when put into tablet mode
event = ibm/hotkey HKEY 00000080 00005009
actions=/etc/acpi/ibm_lid.sh tablet


The /etc/acpi/ibm_lid.sh contains the bash scripts to do the rotation. Mine looks like this:
Code:

#! /bin/bash

USER=`ps -eo user,comm | grep X | awk '{print $1}'`
if [ $USER ]; then
  if [ $1 = "tablet" ]; then
    ORIENTATION="right"
    ROTATION="1"
  else
    ORIENTATION="normal"
    ROTATION="0"
  fi

  sudo -u $USER xrandr -o $ORIENTATION -display ":0"
  sudo -u $USER xsetwacom -d ":0" set stylus rotate $ROTATION
  sudo -u $USER xsetwacom -d ":0" set stylus rotate $ROTATION
fi


Make sure the script is executable. That way it only actually runs if X is running since it's rather pointless if X is not. It seems to work for me, but I haven't tested it thoroughly. You will have to re-load the ibm_acpi module and restart the acpid daemon to make the changes take effect.

You need to use >=x11-drivers/xf86-video-i810-1.6.5 for rotation to work, which is masked. You also need to apply the rotation patch to the linuxwacom package.

I have some of the tablet buttons on the screen working. Add:
Code:
setkeycodes 6e 109 6d 104 69 28 6b 1 6c 120

to your local.start and that will activate the PageUp, PageDown, Enter, and Esc keys. I'm still looking into the the other two. Now that the rotation script works, it should be possible to use that for the rotation button. I was hoping to use the other hotkey for on-screen keyboard.

Let me know if this works.
Back to top
View user's profile Send private message
truc
Advocate
Advocate


Joined: 25 Jul 2005
Posts: 3199

PostPosted: Sun Sep 10, 2006 11:03 pm    Post subject: Reply with quote

I wil try to play with this ASAP, but, actually, it's for my TFT screen, and so there is nothing specific to it in the kernel config ..

So I was articularly interested inthe ACPI thing.

Thanks!
_________________
The End of the Internet!
Back to top
View user's profile Send private message
mog
Apprentice
Apprentice


Joined: 05 Jul 2003
Posts: 253
Location: Auckland [NZ]

PostPosted: Thu Sep 14, 2006 11:22 am    Post subject: Reply with quote

same story here ... I bought a Samsung 940B LCD panel and have managed to get it to swivel via an entry in my fluxbox menu, but I was wondering if this could work for me too ...

how do I find out if there is any ACPI event from the monitor?
_________________
To thine own self be true.
Back to top
View user's profile Send private message
DooBeDooBeDo
Apprentice
Apprentice


Joined: 21 Aug 2002
Posts: 220
Location: UK

PostPosted: Thu Sep 14, 2006 11:35 am    Post subject: Re: X Screen Rotation via ACPI? Reply with quote

tomatopi wrote:
I've got an IBM X41 Tablet I'm putting Gentoo on. Everything seems to work quite well so far with a couple patches. Screen rotation works using a couple commands, which is great.
Code:
xrandr -o normal
xsetwacom set stylus rotate 0

This tablet actually sends an ACPI Hotkey event when the screen is rotated into tablet or laptop position. I've got acpid to try and run those rotation commands to automatically rotate the screen, but it doesn't work. I a "Cannot open display" error. I would guess those commands are being run as acpid user and it can't connect to the logged on user's X Session for the rotation to actually work.

Any ideas how to get this type of thing to work?


In your acpi script change your commands to set $DISPLAY
eg.
Code:
DISPLAY=:0.0 xrandr -o normal
DISPLAY=:0.0 xsetwacom set stylus rotate 0
Back to top
View user's profile Send private message
anjames
Tux's lil' helper
Tux's lil' helper


Joined: 30 Jul 2004
Posts: 115
Location: San Diego, CA

PostPosted: Sun Sep 24, 2006 6:57 pm    Post subject: Reply with quote

I have a Toshiba portege m200 and am interested in doing the same thing here, but don't know how you get the rotation status from the acpi event. When I close and then open the lid, I get the following printed to /var/log/acpid:
Code:
[Sun Sep 24 11:00:48 2006] received event "button/lid LID 00000080 00000005"
[Sun Sep 24 11:00:48 2006] notifying client 7105[102:408]
[Sun Sep 24 11:00:48 2006] executing action "logger "Caught event: button/lid LID 00000080 00000005.""
[Sun Sep 24 11:00:48 2006] BEGIN HANDLER MESSAGES
[Sun Sep 24 11:00:48 2006] END HANDLER MESSAGES
[Sun Sep 24 11:00:48 2006] action exited with status 0
[Sun Sep 24 11:00:48 2006] completed event "button/lid LID 00000080 00000005"
[Sun Sep 24 11:00:50 2006] received event "button/lid LID 00000080 00000006"
[Sun Sep 24 11:00:50 2006] notifying client 7105[102:408]
[Sun Sep 24 11:00:50 2006] executing action "logger "Caught event: button/lid LID 00000080 00000006.""
[Sun Sep 24 11:00:50 2006] BEGIN HANDLER MESSAGES
[Sun Sep 24 11:00:50 2006] END HANDLER MESSAGES
[Sun Sep 24 11:00:50 2006] action exited with status 0
[Sun Sep 24 11:00:50 2006] completed event "button/lid LID 00000080 00000006"

where the number at the end of the received event line (here 00000005 and 00000006) is incremented every time a lid event occurs.

When I rotate the screen, close the lid (ie put it in 'tablet mode') and then reverse these steps, I get no acpi events at all. Argh.

Info on other ACPI events:
    There are periodic battery events passed, which I use to keep tabs on the battery level, but these don't get me screen rotation.

    When I disconnect the ac-adapter, I get ac-adapter and processor events ending in 00000000, reconnecting the adapter gets me the same events but now ending in 00000001. I guess I could use this to change power profiles, screen intensity, etc when on battery power.


I'm not exactly sure but I'm guessing that this is what's going on:
acpid opens the file /proc/acpi/events and watches for an 'event' to occur.
The question here seems to be, what exactly defines an 'event'?
When I press the lid button (or close the lid) or connect/disconnect the ac-adapter, acpid registers one or more 'events' and logs them to /var/log/acpid.
The battery is periodically polled (by a hardware timer? every ~30s or so) and issues an acpi event.
Other events can occur, rotating of screens, pressing of buttons, etc. but they are not understood by acpid so they are ignored. How can we read ALL the events, not just understood ones?

What we need to do then is teach acpi to understand our particular event, and there are at least two ways to do this:
    I fear that this has got something to do with the dreaded acpi DSDT (AHHHH!!!). You have to decompile it, and have a look at the assembly (ugly machine code) to see what is going on.

    There may be another way! Probably there's a register somewhere that gets changed when these 'events' occur, so if we could watch that register and compare the values in differents states, perhaps we could find out what our desired 'event' changes in the register and patch acpid to understand it.


Just a thought anyway!

I'm going to have a dig in my DSDT and see if there's anything useful in there, just because I've never done it before. I feel like some sort of explorer, riding my hawse in the wild west and conquering new frontiers. Yay. I'll yell if I find anything interesting.
Back to top
View user's profile Send private message
anjames
Tux's lil' helper
Tux's lil' helper


Joined: 30 Jul 2004
Posts: 115
Location: San Diego, CA

PostPosted: Sun Sep 24, 2006 8:06 pm    Post subject: Reply with quote

jetblack wrote a lengthy HOWTO on DSDTs which includes:
Quote:
DSDT describes the configuration of your system. It has definitions of all of the devices that ACPI supports, and describes their capabilities.

It sounds like this is the right place to start. Once again, I'll let you know when I've gotten somewhere else.
Back to top
View user's profile Send private message
phorn
Tux's lil' helper
Tux's lil' helper


Joined: 01 Jul 2006
Posts: 109

PostPosted: Sun Sep 24, 2006 8:39 pm    Post subject: Re: X Screen Rotation via ACPI? Reply with quote

DooBeDooBeDo wrote:
In your acpi script change your commands to set $DISPLAY
eg.
Code:
DISPLAY=:0.0 xrandr -o normal
DISPLAY=:0.0 xsetwacom set stylus rotate 0


You may need to make sure that X uses the proper .Xauthority file. Not doing so may also result in a "Cannot open display" error.

You may want to try
Code:
XAUTHORITY=/home/XUSERNAME/.Xauthority DISPLAY=:0.0 xrandr -o normal
XAUTHORITY=/home/XUSERNAME/.Xauthority DISPLAY=:0.0 xsetwacom set stylus rotate 0
Back to top
View user's profile Send private message
bushvin
Tux's lil' helper
Tux's lil' helper


Joined: 20 Feb 2004
Posts: 142
Location: Leuven, Belgium

PostPosted: Fri Oct 13, 2006 8:59 am    Post subject: Reply with quote

Hi there...

How did you get the 'rotate' parameter in xsetwacom?

I read on the wacom site it requires a patch. did you compile linuxwacom manually or did you apply a patch?

my linuxwacom ebuild is x11-drivers/linuxwacom-0.7.4_p3

thanks for any help pointing me in the right direction.

Will.
_________________
"Don't be too proud of this technological terror you've constructed. The ability to destroy a planet is insignificant next to the power of the Force." - Lord Vader
Back to top
View user's profile Send private message
tomatopi
Tux's lil' helper
Tux's lil' helper


Joined: 18 Sep 2005
Posts: 130
Location: Ottawa

PostPosted: Fri Oct 13, 2006 12:56 pm    Post subject: Reply with quote

I got the rotate patch from Xournal Wesbite.

The changelog of linuxwacom says the rotate patch was integrated in August, but I don't think that version is in Portage yet.

I patched it by using Ctrl-X after the souce files were unpacked, applied the patch, then used fg to continue building the packaged. Seemed to work fine. The patch is listed for an older version of linuxwacom, but it does seem to work fine.
Back to top
View user's profile Send private message
bushvin
Tux's lil' helper
Tux's lil' helper


Joined: 20 Feb 2004
Posts: 142
Location: Leuven, Belgium

PostPosted: Sun Oct 15, 2006 11:31 am    Post subject: Reply with quote

got it.

Excuse my ignorance, but I'm kindof new applying patches...

I found a patch file through this site.

How do I apply this patch?

Thanks in advance,

Will.
_________________
"Don't be too proud of this technological terror you've constructed. The ability to destroy a planet is insignificant next to the power of the Force." - Lord Vader
Back to top
View user's profile Send private message
bushvin
Tux's lil' helper
Tux's lil' helper


Joined: 20 Feb 2004
Posts: 142
Location: Leuven, Belgium

PostPosted: Sun Oct 15, 2006 11:45 am    Post subject: Reply with quote

I'm sorry, I just found out. It turned out Rotate was compiled successfully into linuxwacom-0.7.4_p3 now.

thanks for your help!
_________________
"Don't be too proud of this technological terror you've constructed. The ability to destroy a planet is insignificant next to the power of the Force." - Lord Vader
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum