You are not logged in.

#1 2011-01-01 23:10:16

NYFinest
Member
From: New York
Registered: 2010-07-23
Posts: 19

Lenovo Thinkpad X201T automatic rotation help.

Hello all,
I have been trying to get auto rotation on my Thinkpad X201 to work, but so far I have been unsuccessful. I would like to get this working properly so I can completley remove Windows of my system.

Thinkwiki article on the X201T

Over at Thinkwiki they covered on how to get this to work on the X200T which I also tried but I changed the script path.
X200T Active Rotate

/etc/acpi/actions/swivel_down.sh

#!/bin/bash
/usr/bin/xrandr -o right 
xsetwacom set "stylus" Rotate cw
xsetwacom set "cursor" Rotate cw
xsetwacom set "eraser" Rotate cw

/etc/acpi/events/swivel_down

event=ibm/hotkey HKEY 00000080 00005009
action=/etc/acpi/actions/swivel_down.sh

/etc/acpi/actions/swivel_up.sh

#!/bin/bash
/usr/bin/xrandr -o normal
xsetwacom set "stylus" Rotate none
xsetwacom set "cursor" Rotate none
xsetwacom set "eraser" Rotate none

/etc/acpi/events/swivel_up

event=ibm/hotkey HKEY 00000080 0000500a
action=/etc/acpi/actions/swivel_up.sh

I also did chmod +x on both .sh files and when I run them in terminal they work perfectly.

/var/log/acipid.log

Jan  1 17:27:18 archakuma acpid: starting up
Jan  1 17:27:18 archakuma acpid: 6 rules loaded
Jan  1 17:27:18 archakuma acpid: waiting for events: event logging is off
Jan  1 17:27:19 archakuma acpid: client connected from 4079[82:82]
Jan  1 17:27:19 archakuma acpid: 1 client rule loaded
Jan  1 17:27:29 archakuma acpid: client connected from 4672[0:100]
Jan  1 17:27:29 archakuma acpid: 1 client rule loaded
Jan  1 17:27:47 archakuma acpid: client connected from 4834[1000:100]
Jan  1 17:27:47 archakuma acpid: 1 client rule loaded
Jan  1 17:32:29 archakuma acpid: exiting
Jan  1 17:33:02 archakuma acpid: starting up
Jan  1 17:33:02 archakuma acpid: 6 rules loaded
Jan  1 17:33:02 archakuma acpid: waiting for events: event logging is off
Jan  1 17:33:03 archakuma acpid: client connected from 4044[82:82]
Jan  1 17:33:03 archakuma acpid: 1 client rule loaded
Jan  1 17:33:17 archakuma acpid: client connected from 4643[0:100]
Jan  1 17:33:17 archakuma acpid: 1 client rule loaded

/var/log/everything.log

Jan  1 17:33:32 archakuma logger: ACPI group/action undefined: ibm/hotkey / HKEY
Jan  1 17:33:37 archakuma logger: ACPI group/action undefined: ibm/hotkey / HKEY
Jan  1 17:34:22 archakuma logger: ACPI group/action undefined: ibm/hotkey / HKEY
Jan  1 17:34:22 archakuma logger: ACPI group/action undefined: video / LCD0
Jan  1 17:34:23 archakuma logger: ACPI group/action undefined: ibm/hotkey / HKEY
Jan  1 17:34:23 archakuma logger: ACPI group/action undefined: video / LCD0

These are the portions of the logs when I rotated the screen. I also noticed that in the Thinkwiki X201T article they do not to seem to cover auto rotation so I wonder if it works? I also tried editing handler.sh as described in the wiki for X60T which is described here. I have the steps commented out in my handler.sh

/etc/acpi/handler.sh

#!/bin/sh
# Default acpi script that takes an entry for all actions

# NOTE: This is a 2.6-centric script.  If you use 2.4.x, you'll have to
#       modify it to not use /sys

minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"

set $*

case "$1" in
#ibm/hotkey)
#                case "$2" in
#                        HKEY)
#                                case "$4" in
#                                        00005009)
#                                               #Swiveling down
#                                               /bin/sh /etc/acpi/actions/swivel_down.sh
#                                        ;;
#                                        0000500a)
#                                               #Swiveling up /bin/sh
#                                                /bin/sh /etc/acpi/actions/swivel_up.sh
#                                        ;;
#                                esac
#                               ;;
#                esac
#                ;;
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PWRF)   logger "PowerButton pressed: $2" ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB)   echo -n mem >/sys/power/state ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode start
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   #echo "offline" >/dev/tty5
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
                    ;;
                esac
                ;;
            CPU0)    
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
        #echo "LID switched!">/dev/tty5
        ;;
    *)
        logger "ACPI group/action undefined: $1 / $2"
        ;;
esac

I also have the thinkpad_acpi and tp_smapi modules loaded at startup. If I have left out any relevant info, I will provide it as soon as I can. I would like to thank everyone in advance for their help! smile


Lenovo X201T
Arch x86_64

Offline

#2 2011-01-02 01:56:03

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: Lenovo Thinkpad X201T automatic rotation help.

Your everything.log shows just a bit too little, if you change the last logger line to $1 / $2 / $3 / $4 we can see if it is catching the right events.


ᶘ ᵒᴥᵒᶅ

Offline

#3 2011-01-02 03:04:57

NYFinest
Member
From: New York
Registered: 2010-07-23
Posts: 19

Re: Lenovo Thinkpad X201T automatic rotation help.

litemotiv wrote:

if you change the last logger line to $1 / $2 / $3 / $4 we can see if it is catching the right events.

Sorry for my ignorance but I don't understand what you mean? Can you kindly explain this to me? I have included a dropbox link to my full everything.log.

Thanks again. smile

http://dl.dropbox.com/u/17786967/everything.log


Lenovo X201T
Arch x86_64

Offline

#4 2011-01-02 10:43:00

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: Lenovo Thinkpad X201T automatic rotation help.

NYFinest wrote:
litemotiv wrote:

if you change the last logger line to $1 / $2 / $3 / $4 we can see if it is catching the right events.

Sorry for my ignorance but I don't understand what you mean? Can you kindly explain this to me? I have included a dropbox link to my full everything.log.

Thanks again. smile

http://dl.dropbox.com/u/17786967/everything.log

This line on your handler.sh:

logger "ACPI group/action undefined: $1 / $2"

logs the ACPI events to everything.log, but right now it only logs the first two variables:

ACPI group/action undefined: ibm/hotkey / HKEY

while you want to see if it receives the same event codes you configured:

event=ibm/hotkey HKEY 00000080 00005009

So if you add two more variables to the logger line, $3 and $4, the codes themselves will be logged as well.


ᶘ ᵒᴥᵒᶅ

Offline

#5 2011-01-03 01:00:04

NYFinest
Member
From: New York
Registered: 2010-07-23
Posts: 19

Re: Lenovo Thinkpad X201T automatic rotation help.

Thanks litemotiv! I added the variables to handler.sh

This is what the end of the file looks like.

    *)
        logger "ACPI group/action undefined: $1 / $2 / $3 / $4"
        ;;
esac

Now here is a portion of everything.log when i rotated the lid.

Jan  2 19:54:16 archakuma logger: ACPI group/action undefined: ibm/hotkey / HKEY / 00000080 / 00005009
Jan  2 19:54:18 archakuma logger: ACPI group/action undefined: ibm/hotkey / HKEY / 00000080 / 0000500a

Lenovo X201T
Arch x86_64

Offline

#6 2011-01-03 08:58:35

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: Lenovo Thinkpad X201T automatic rotation help.

NYFinest wrote:

Now here is a portion of everything.log when i rotated the lid.

Jan  2 19:54:16 archakuma logger: ACPI group/action undefined: ibm/hotkey / HKEY / 00000080 / 00005009
Jan  2 19:54:18 archakuma logger: ACPI group/action undefined: ibm/hotkey / HKEY / 00000080 / 0000500a

That looks alright. smile

What happens if you just place a logger line in your handler.sh, or put your xrandr code there directly? Like this:

ibm/hotkey)
                case "$2" in
                        HKEY)
                                case "$4" in
                                        00005009)
                                               #Swiveling down
                                               logger "This is a test"
                                               xrandr -o right
                                        ;;
                                        0000500a)
                                               #Swiveling up /bin/sh
                                                /bin/sh /etc/acpi/actions/swivel_up.sh
                                        ;;
                                esac
                               ;;
                esac

ᶘ ᵒᴥᵒᶅ

Offline

#7 2011-01-03 11:33:50

eldragon
Member
From: Buenos Aires
Registered: 2008-11-18
Posts: 1,029

Re: Lenovo Thinkpad X201T automatic rotation help.

check if xsetwacom requieres privileges from your user or some environmental variables to setup the devices. it could also be a dbus thing.

Offline

#8 2011-01-03 12:43:12

NYFinest
Member
From: New York
Registered: 2010-07-23
Posts: 19

Re: Lenovo Thinkpad X201T automatic rotation help.

litemotiv wrote:

What happens if you just place a logger line in your handler.sh, or put your xrandr code there directly?

This is how my handler.sh looks like now

#!/bin/sh
# Default acpi script that takes an entry for all actions

# NOTE: This is a 2.6-centric script.  If you use 2.4.x, you'll have to
#       modify it to not use /sys

minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"

set $*

case "$1" in
ibm/hotkey)
                case "$2" in
                        HKEY)
                                case "$4" in
                                        00005009)
                                               #Swiveling down
                                               logger "This is a test"
                                               xrandr -o right
                                        ;;
                                        0000500a)
                                               #Swiveling up /bin/sh
                                                /bin/sh /etc/acpi/actions/swivel_up.sh
                                        ;;
                                esac
                               ;;
                esac
                ;;
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PWRF)   logger "PowerButton pressed: $2" ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/sleep)
        case "$2" in
            SLPB)   echo -n mem >/sys/power/state ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode start
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   #echo "offline" >/dev/tty5
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
                    ;;
                esac
                ;;
            CPU0)    
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
        #echo "LID switched!">/dev/tty5
        ;;
    *)
        logger "ACPI group/action undefined: $1 / $2 / $3 / $4"
        ;;
esac

I rotated the lid twice. Once with swivel_down and swivel_up in the /etc/events/ directory and the other time i removed those two events from the folder. Each time everything.log showed this

Jan  3 07:30:25 archakuma logger: This is a test
Jan  3 07:30:41 archakuma logger: This is a test
eldragon wrote:

check if xsetwacom requieres privileges from your user or some environmental variables to setup the devices. it could also be a dbus thing.

If I remember correctly xsetwacom does not require privileges but I could be wrong. How can I check this for sure? I do have the option for xrandr rotation in my Xorg.conf and if I link a script to my Tablet rotate button it does rotate.

Thanks again for everyones assistance.


Lenovo X201T
Arch x86_64

Offline

#9 2011-01-03 13:06:57

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: Lenovo Thinkpad X201T automatic rotation help.

Maybe you need the display environment variable set?

DISPLAY="0:0" xrandr -o right

ᶘ ᵒᴥᵒᶅ

Offline

#10 2011-01-03 14:31:36

NYFinest
Member
From: New York
Registered: 2010-07-23
Posts: 19

Re: Lenovo Thinkpad X201T automatic rotation help.

litemotiv wrote:

Maybe you need the display environment variable set?

DISPLAY="0:0" xrandr -o right

Am I correct in assuming that this would go in handler.sh?


Lenovo X201T
Arch x86_64

Offline

#11 2011-01-03 14:40:04

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: Lenovo Thinkpad X201T automatic rotation help.

NYFinest wrote:
litemotiv wrote:

Maybe you need the display environment variable set?

DISPLAY="0:0" xrandr -o right

Am I correct in assuming that this would go in handler.sh?

Yes you can place that instead of the xrandr line i gave earlier.


ᶘ ᵒᴥᵒᶅ

Offline

#12 2011-01-04 01:25:47

NYFinest
Member
From: New York
Registered: 2010-07-23
Posts: 19

Re: Lenovo Thinkpad X201T automatic rotation help.

This is a portion of my handler.sh

case "$2" in
                        HKEY)
                                case "$4" in
                                        00005009)
                                               #Swiveling down
                                               logger "This is a test"
                                               DISPLAY="0:0" xrandr -o right
                                        ;;

This is all that comes up in everything.log, so the screen is not rotating when i rotate the lid

Jan  3 20:38:25 archakuma logger: This is a test

And for reference here is my 10-monitor.conf

Section "Monitor"
    Identifier    "Monitor0"
EndSection

Section "Device"
    Identifier    "Device0"
    Driver        "intel"
EndSection

Section "Screen"
    Identifier    "Screen0"  
    Device        "Device0"
    Monitor       "Monitor0"
    Option         "RandRRotation" "on"
EndSection

Thanks again for your help, I appreciate it. smile


Lenovo X201T
Arch x86_64

Offline

#13 2011-01-05 12:44:56

NYFinest
Member
From: New York
Registered: 2010-07-23
Posts: 19

Re: Lenovo Thinkpad X201T automatic rotation help.

I have been searching and reading around and I found a post that help me realize the problem I was having.
https://bbs.archlinux.org/viewtopic.php?pid=719845

I commented any changes I did to the handler.sh and put everything back in the /etc/events/ directory, then I restarted acpid through the terminal and the rotated the lid and the script worked how it was supposed to. I could of found out this was the problem if I had done this is the first place but i was just rebooting the whole system sad.

Now from what i gathered in the post was that the problem is that acpid starts before X starts. Is there a way to do this with out manually restarting acpid? In my Daemons section in rc.conf I have dbus and hal.

Thanks.


Lenovo X201T
Arch x86_64

Offline

Board footer

Powered by FluxBB