In two old posts I described, how you could use the gyro sensor of the Acer 1825 for auto rotating your screen and how you could enable and disable this feature with a special button.
http://www.ceh-photo.de/blog/?p=244
http://www.ceh-photo.de/blog/?p=186
A user (perpe) from http://ubuntuforums.org/showthread.php?t=1486671&page=13 found out, that in windows the gyro sensor is enabled and disabled with some special keyboard events.
He found these keyboard events after doing a bios update to version 1.3127. Because of some problems I always did this update and could not check if the presented procedure works with older bios.
Make the special key commands usable:
You need to specify the keycodes for these commands in your /etc/rc.local
Next update both old scripts:
/usr/bin/gyro-auto-rotate.run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | #!/bin/bash # DEBUG="" # write DEBUG="1" for debugging #redirect stdin, stdout and stderr [ ! "${DEBUG}" ] && exec>/dev/null 2>&1 # daemonize and exit [ ! "${DEBUG}" ] && [ -z "$PPID" ] && { PPID=$$ $0 & exit 0; } init() { modprobe i2c-i801 >/dev/null 2>&1 modprobe i2c-dev >/dev/null 2>&1 } rotate() { xrandr -o $1 case $1 in normal) xinput set-prop "$id" "Evdev Axis Inversion" 0, 0 xinput set-prop "$id" "Evdev Axes Swap" 0 xinput set-prop "$id" "Evdev Axis Calibration" $calibx $caliby ;; inverted) xinput set-prop "$id" "Evdev Axis Inversion" 1, 1 xinput set-prop "$id" "Evdev Axes Swap" 0 xinput set-prop "$id" "Evdev Axis Calibration" $calibx $caliby ;; left) xinput set-prop "$id" "Evdev Axis Inversion" 1, 0 xinput set-prop "$id" "Evdev Axes Swap" 1 xinput set-prop "$id" "Evdev Axis Calibration" $caliby $calibx ;; right) xinput set-prop "$id" "Evdev Axis Inversion" 0, 1 xinput set-prop "$id" "Evdev Axes Swap" 1 xinput set-prop "$id" "Evdev Axis Calibration" $caliby $calibx esac } get_orientation() { set `i2c-gsensor 0` x=$3 y=$6 z=$9 if [[ ( $x -gt 0 ) && ( $x -lt 60 ) ]] && [[ ( $y -gt 247 ) || ( $y -lt 10 ) ]] then # laptop mod = normal tablet mode = inverted new_orientation="inverted" elif [ $y -lt 248 ] && [ $y -gt 190 ] then # laptop mod = right tablet mode = left new_orientation="left" elif [ $y -lt 60 ] && [ $y -gt 10 ] then # laptop mod = left tablet mode = right new_orientation="right" else # laptop mod = inverted tablet mode = normal new_orientation="normal" fi echo $new_orientation } loop() { while [ 1 ] do sleep 3 get_orientation if [ "${new_orientation}" != "${orientation}" ] then rotate ${new_orientation} orientation=${new_orientation} fi echo "x: $x y: $y z: $z" done } # MAIN #----- trap - EXIT #Initialisation PATH="$PATH:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" prog=`basename $0` caliby="0 10751" calibx="0 18943" init [ "$id" ] || id="`xinput list | grep Cando \ | sed -n -e's/.*id=\([0-9]\+\).*/\1/p'`" [ "$id" ] || id="`xinput list | grep touchscreen \ | sed -n -e's/.*id=\([0-9]\+\).*/\1/p'`" [ "$id" ] || { echo " Touch screen not found..." & exit 1; } orientation=`xrandr --query --verbose | awk ' ($1=="LVDS1") {print $5} '` new_orientation="${orientation}" #if got argument do not jump into loop if [[ $# -gt 0 ]];then rotate $1 else loop fi exit 0 |
/usr/bin/gyro-key.run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #!/bin/bash pid=$( pgrep gyro-auto-rotat ) if [[ $1 == "activate" ]];then #DO NOT START TWICE if [ "$pid" == "" ] ;then gyro-auto-rotate.run & fi notify-send "gyro auto rotation enabled --> tablet mode" else if [[ $1 == "deactivate" ]];then if [ "$pid" != "" ] ;then kill -9 $pid #reset screen to default gyro-auto-rotate.run normal fi notify-send "gyro auto rotation disabled --> laptop mode" else notify-send "No param" fi fi |
I use a tool for displaying me desktop notifications if gyro rotations is enabled or disabled. If you want to use it, you need to install the package libnotify-bin with
sudo apt-get install libnotify-bin
if you don’t want the feature please uncomment all lines with notify-send.
After that you need to update your key-bindings in gnome-keybinding-properties.
Take a look at my configuration:
you need to call the script gyro-key.run one time with parameter deactivate and one time with activate to enable and disable the gyro auto rotation. See example on the screenshot.
The backup-button is now free for other commands. I use it as button for fullscreen-mode.
[…] my last post I explained were you found a tutorial for installing a real multitouch driver for the ACER 1825 and […]
I did not like the idea of dedicating the only button in converted mode to a onscreen keyboard.
So i added an entry for the onscreen keyboard to the gnome menu under acessories. Then i added the onscreen keyboard to the Favorites in netbook-launcher with the command:
netbook-launcher –add-favorite /usr/bin/onboard
and set the P-button to execute: netbook-launcher –show-favorites
Now when i hit the P-button, the favorites pop up and i can select from the applications scripts …. whatever i want ^^
rock & roll
B4ckBOne
Interesting approach, but check the improved again script:
http://www.ceh-photo.de/blog/?p=336 It places and resizes the keyboard and the current active window for nice access.
Found an issue with your script.
The part:
———————-code———————————
xinput set-prop “$id” “Evdev Axis Inversion” 1, 0
xinput set-prop “$id” “Evdev Axes Swap” 1
xinput set-prop “$id” “Evdev Axis Calibration” $caliby $calibx
;;
right)
xinput set-prop “$id” “Evdev Axis Inversion” 0, 1
xinput set-prop “$id” “Evdev Axes Swap” 1
xinput set-prop “$id” “Evdev Axis Calibration” $caliby $calibx
esac
}
—————————–\code————————-
does not work on my lucid install with single touch Cando driver setup:
——————————\xinput list——————–
:~$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Cando 11.6 id=10 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ CNF9011 id=11 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)]
————————–\xinput list————————————-
but if you change it to this for use with cando driver:
————————–switched caliby & claibx ———————-
;;
left)
xinput set-prop “$id” “Evdev Axis Inversion” 1, 0
xinput set-prop “$id” “Evdev Axes Swap” 1
xinput set-prop “$id” “Evdev Axis Calibration” $calibx $caliby
;;
right)
xinput set-prop “$id” “Evdev Axis Inversion” 0, 1
xinput set-prop “$id” “Evdev Axes Swap” 1
xinput set-prop “$id” “Evdev Axis Calibration” $calibx $caliby
esac
}
————————–\end—————————–
it works for use with Lucid Cando kernel 2.6.35 without messing up calibration.
Notice, only $calibx and $caliby variables have been switched to stay the way they are in normal and inverted mode.
This did the trick for me 🙂
rock & roll
B4ckBOne
I wrote a udev rule to change the owner of the gyro device automatically.
Simply make a file in /lib/udev/rules.d/ called 30-g-sensor.rules
(you need root provileges for that)
and put:
KERNEL==”i2c-[0-7]”, OWNER=”user”, GROUP=”user”
in it, while replacing user with you username.
then reboot or run:
sudo service udev reload && sudo udevadm trigger
Hey thanks for that reply! I did not have problems with the rights but some others have it.