<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jonasbergel</id>
	<title>ThinkWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.thinkwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jonasbergel"/>
	<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/wiki/Special:Contributions/Jonasbergel"/>
	<updated>2026-04-07T10:57:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.12</generator>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=40167</id>
		<title>How to rotate X41t screen with gravity sensor(hdaps)</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=40167"/>
		<updated>2008-12-08T23:57:01Z</updated>

		<summary type="html">&lt;p&gt;Jonasbergel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[:Category:X41 Tablet|X41 Tablet]][[Category:X41 Tablet]][[Category:Scripts]]&lt;br /&gt;
&lt;br /&gt;
The X41t has a acceleration sensor build in. Originally it can protect the hard drive, if Laptop is falling down. See the [[HDAPS]] Page.&lt;br /&gt;
Now lets use that for funny stuff like emulate a joystick for Neverball [http://de.wikipedia.org/wiki/Neverball]. Or we use it for a very useful thing: Rotating the screen by recognizing where is downward. Like a lot of handy tools, like mobiles, mp3 player or photo cameras.&lt;br /&gt;
&lt;br /&gt;
 Basic concept is the following: &lt;br /&gt;
 -Rotate the screen and the stylus to the steepest decent direction.&lt;br /&gt;
 -Rotate only in stylus mode.&lt;br /&gt;
 -Rotate only if it is really necessary.&lt;br /&gt;
 -Rotate only if it cants more than 10 degrees.&lt;br /&gt;
 -An easy program.&lt;br /&gt;
&lt;br /&gt;
There are other programs witch can do that, but I have not found one that works out off the box. And I can not understand that much ''python''. So I tried it out myself.&lt;br /&gt;
I have written a set of small ''shell'' scripts that rotates the screen of the X41 Tablet by using the gravity sensor coordinates and some ACPI events.&lt;br /&gt;
It consist of two parts, fist the main part that contains the code for deciding and rotating and the second part which starts and stops the fist one. Maybe some one can make suggestions to get this in a real deamon style. &lt;br /&gt;
&lt;br /&gt;
I have tested it on an x41t with ubuntu 8.04 with the standard kernel 2.6.24-19-generic.&lt;br /&gt;
 ''sudo apt-get install x11-xserver-utils wacom-tools'' should install all stuff.&lt;br /&gt;
&lt;br /&gt;
First Part. Usually this is saved as {{path|/etc/acpid/x41t_gravity}}&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
  &lt;br /&gt;
 #usage: just start or kill it&lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 get_orientation(){&lt;br /&gt;
     string=`cat /sys/devices/platform/hdaps/position`&lt;br /&gt;
     string=`echo $string | tr -d '[=-=][:blank:][=(=][=)=]'`&lt;br /&gt;
     x=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $1}'`&lt;br /&gt;
     y=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $2}'`&lt;br /&gt;
     dx=`expr $x - $x_horizontal`		#dx away from middle&lt;br /&gt;
     dy=`expr $y - $y_horizontal`		#dy away form the middle&lt;br /&gt;
     &lt;br /&gt;
      #get actual orientation from last rotation, saved in a file :&lt;br /&gt;
     if [ ! -f /tmp/actual_orientation.txt ];then&lt;br /&gt;
     	echo 0 &amp;gt; /tmp/actual_orientation.txt		#0 means normal orientation&lt;br /&gt;
     fi&lt;br /&gt;
     actual_orientation=`cat /tmp/actual_orientation.txt`&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prepare_rotate(){&lt;br /&gt;
             echo &amp;quot;Nothing to prepare. I can rotate now.&amp;quot;&lt;br /&gt;
 	    #ps -A | grep compiz.real &amp;amp;&amp;amp; (kwin --replace)&amp;amp;	#because compiz sometimes crashes. &lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
 do_rotate(){&lt;br /&gt;
 	    prepare_rotate&lt;br /&gt;
 	    #rotate screen&lt;br /&gt;
 	    xrandr -o $1&lt;br /&gt;
 	    #rotate stylus&lt;br /&gt;
  	    case $1 in&lt;br /&gt;
     		right)&lt;br /&gt;
     		    /usr/bin/xsetwacom set stylus rotate 1;;&lt;br /&gt;
 		left)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 2;;&lt;br /&gt;
 		inverted)	&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 3;;&lt;br /&gt;
     		*)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 0;;&lt;br /&gt;
 	    esac&lt;br /&gt;
 	    #save the orientation			&lt;br /&gt;
 	    echo $1 &amp;gt; /tmp/actual_orientation.txt&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ######### Main ########################&lt;br /&gt;
 &lt;br /&gt;
 while [ true ]; do&lt;br /&gt;
     get_orientation    &lt;br /&gt;
      if [ `expr $dx \* $dx` -ge `expr $dy \* $dy` ];then #checks for the absolute greater value &lt;br /&gt;
  	if [ $dx -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = right ] ;then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate right&lt;br /&gt;
 	elif [ $dx -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = left ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate left&lt;br /&gt;
 	fi&lt;br /&gt;
     else&lt;br /&gt;
 	if [ $dy -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = normal ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate normal&lt;br /&gt;
 	elif [ $dy -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = inverted ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate inverted&lt;br /&gt;
 	fi&lt;br /&gt;
     fi&lt;br /&gt;
     sleep 1&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Second Part. Usually this is saved as {{path|/etc/acpid/x41t_control_gravity.sh}}&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 ################ set DISPLAY ####################&lt;br /&gt;
 export DISPLAY=$Default_DISPLAY		#a work around for right DISPLAY varialbe (I do not like it).&lt;br /&gt;
 export XAUTHORITY=$Default_XAUTHORITY&lt;br /&gt;
 xset -display $DISPLAY dpms&lt;br /&gt;
&lt;br /&gt;
 ################# Main ##########################&lt;br /&gt;
 &lt;br /&gt;
 if [ ! $1 ] || [ ! $1 = start ];then&lt;br /&gt;
     killall x41t_gravity		#return to normal state&lt;br /&gt;
     xrandr -o normal &lt;br /&gt;
     /usr/bin/xsetwacom set stylus rotate 0&lt;br /&gt;
     rm /tmp/actual_orientation.txt&lt;br /&gt;
 elif [ $1 = start ];then&lt;br /&gt;
     #check for the kernel modul for gyroscope&lt;br /&gt;
     lsmod | grep hdaps || modprobe hdaps&lt;br /&gt;
     lsmod | grep hdaps || exit 1&lt;br /&gt;
     (/etc/acpi/x41t_gravity)&amp;amp;		#will be endless repeated (kill see up)&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
Some settings that have to tune. Usually this is saved as {{path|/etc/gravity/gravity.conf}}&lt;br /&gt;
&lt;br /&gt;
 x_horizontal=433	#horizontal position, get it by calibration&lt;br /&gt;
 y_horizontal=390	#just read the value in /sys/devices/platform/hdaps/position&lt;br /&gt;
 			#the first value is x, second one is y&lt;br /&gt;
 &lt;br /&gt;
 eps=40			#define a neighbourhood interpreted as horizontal&lt;br /&gt;
 &lt;br /&gt;
 Default_DISPLAY=&amp;quot;:0.0&amp;quot;&lt;br /&gt;
 Default_XAUTHORITY=/home/smjb0803/.Xauthority&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now lets begin! Just add two ACPI events, first to start the ''x41t_gravity'', second for ending it. &lt;br /&gt;
&lt;br /&gt;
Fist. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-down}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-down&lt;br /&gt;
 # called when tablet head swivels down&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00005009&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh start&lt;br /&gt;
&lt;br /&gt;
Second. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-up}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-up&lt;br /&gt;
 # called when tablet head swivels up&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 0000500a&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh stop&lt;br /&gt;
&lt;br /&gt;
And restart the ACPID.&lt;br /&gt;
  sudo /etc/init.d/acpid restart&lt;br /&gt;
&lt;br /&gt;
That`s it. Have fun and make suggestions. Please use it only if you trust in it. On personal risk. You have to prevent losing data. &lt;br /&gt;
--[[User:Jonasbergel|Jonasbergel]] 09:27, 16 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Jonasbergel</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=39152</id>
		<title>How to rotate X41t screen with gravity sensor(hdaps)</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=39152"/>
		<updated>2008-10-20T21:08:25Z</updated>

		<summary type="html">&lt;p&gt;Jonasbergel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[:Category:X41 Tablet|X41 Tablet]][[Category:X41 Tablet]][[Category:Scripts]]&lt;br /&gt;
&lt;br /&gt;
The X41t has a acceleration sensor build in. Originally it can protect the hard drive, if Laptop is falling down. See the [[HDAPS]] Page.&lt;br /&gt;
Now lets use that for funny stuff like emulate a joystick for Neverball [http://de.wikipedia.org/wiki/Neverball]. Or we use it for a very useful thing: Rotating the screen by recognizing where is downward. Like a lot of handy tools, like mobiles, mp3 player or photo cameras.&lt;br /&gt;
&lt;br /&gt;
 Basic concept is the following: &lt;br /&gt;
 -Rotate the screen and the stylus to the steepest decent direction.&lt;br /&gt;
 -Rotate only in stylus mode.&lt;br /&gt;
 -Rotate only if it is really necessary.&lt;br /&gt;
 -Rotate only if it cants more than 10 degrees.&lt;br /&gt;
 -An easy program.&lt;br /&gt;
&lt;br /&gt;
There are other programs witch can do that, but I have not found one that works out off the box. And I can not understand that much ''python''. So I tried it out myself.&lt;br /&gt;
I have written a set of small ''shell'' scripts that rotates the screen of the X41 Tablet by using the gravity sensor coordinates and some ACPI events.&lt;br /&gt;
It consist of two parts, fist the main part that contains the code for deciding and rotating and the second part which starts and stops the fist one. Maybe some one can make suggestions to get this in a real deamon style. &lt;br /&gt;
&lt;br /&gt;
I have tested it on an x41t with ubuntu 8.04 with the standard kernel 2.6.24-19-generic.&lt;br /&gt;
 ''sudo apt-get install x11-xserver-utils wacom-tools'' should install all stuff.&lt;br /&gt;
&lt;br /&gt;
First Part. Usually this is saved as {{path|/etc/acpid/x41t_gravity}}&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
  &lt;br /&gt;
 #usage: just start or kill it&lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 get_orientation(){&lt;br /&gt;
     string=`cat /sys/devices/platform/hdaps/position`&lt;br /&gt;
     string=`echo $string | tr -d '[=-=][:blank:][=(=][=)=]'`&lt;br /&gt;
     x=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $1}'`&lt;br /&gt;
     y=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $2}'`&lt;br /&gt;
     dx=`expr $x - $x_horizontal`		#dx away from middle&lt;br /&gt;
     dy=`expr $y - $y_horizontal`		#dy away form the middle&lt;br /&gt;
     &lt;br /&gt;
      #get actual orientation from last rotation, saved in a file :&lt;br /&gt;
     if [ ! -f /tmp/actual_orientation.txt ];then&lt;br /&gt;
     	echo 0 &amp;gt; /tmp/actual_orientation.txt		#0 means normal orientation&lt;br /&gt;
     fi&lt;br /&gt;
     actual_orientation=`cat /tmp/actual_orientation.txt`&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prepare_rotate(){&lt;br /&gt;
             echo &amp;quot;Nothing to prepare. I can rotate now.&amp;quot;&lt;br /&gt;
 	    #ps -A | grep compiz.real &amp;amp;&amp;amp; (kwin --replace)&amp;amp;	#because compiz sometimes crashes. &lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
 do_rotate(){&lt;br /&gt;
 	    prepare_rotate&lt;br /&gt;
 	    #rotate screen&lt;br /&gt;
 	    xrandr -o $1&lt;br /&gt;
 	    #rotate stylus&lt;br /&gt;
  	    case $1 in&lt;br /&gt;
     		right)&lt;br /&gt;
     		    /usr/bin/xsetwacom set stylus rotate 1;;&lt;br /&gt;
 		left)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 2;;&lt;br /&gt;
 		inverted)	&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 3;;&lt;br /&gt;
     		*)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 0;;&lt;br /&gt;
 	    esac&lt;br /&gt;
 	    #save the orientation			&lt;br /&gt;
 	    echo $1 &amp;gt; /tmp/actual_orientation.txt&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ######### Main ########################&lt;br /&gt;
 &lt;br /&gt;
 while [ true ]; do&lt;br /&gt;
     get_orientation    &lt;br /&gt;
      if [ `expr $dx \* $dx` -ge `expr $dy \* $dy` ];then #checks for the absolute greater value &lt;br /&gt;
  	if [ $dx -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = right ] ;then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate right&lt;br /&gt;
 	elif [ $dx -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = left ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate left&lt;br /&gt;
 	fi&lt;br /&gt;
     else&lt;br /&gt;
 	if [ $dy -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = normal ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate normal&lt;br /&gt;
 	elif [ $dy -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = inverted ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate inverted&lt;br /&gt;
 	fi&lt;br /&gt;
     fi&lt;br /&gt;
     sleep 1&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Second Part. Usually this is saved as {{path|/etc/acpid/x41t_control_gravity.sh}}&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 ################ set DISPLAY ####################&lt;br /&gt;
 export DISPLAY=$Default_DISPLAY		#a work around for right DISPLAY varialbe (I do not like it).&lt;br /&gt;
 export XAUTHORITY=$Default_XAUTHORITY&lt;br /&gt;
 xset -display $DISPLAY dpms&lt;br /&gt;
&lt;br /&gt;
 ################# Main ##########################&lt;br /&gt;
 &lt;br /&gt;
 if [ ! $1 ] || [ ! $1 = start ];then&lt;br /&gt;
     killall x41t_gravity		#return to normal state&lt;br /&gt;
     xrandr -o normal &lt;br /&gt;
     /usr/bin/xsetwacom set stylus rotate 0&lt;br /&gt;
     rm /tmp/actual_orientation.txt&lt;br /&gt;
 elif [ $1 = start ];then&lt;br /&gt;
     #check for the kernel modul for gyroscope&lt;br /&gt;
     lsmod | grep hdaps || modprobe hdaps&lt;br /&gt;
     lsmod | grep hdaps || exit 1&lt;br /&gt;
     (/etc/acpi/x41t_gravity)&amp;amp;		#will be endless repeated (kill see up)&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
Some settings that have to tune. Usually this is saved as {{path|/etc/gravity/gravity.conf}}&lt;br /&gt;
&lt;br /&gt;
 x_horizontal=433	#horizontal position, get it by calibration&lt;br /&gt;
 y_horizontal=390	#just read the value in /sys/devices/platform/hdaps/position&lt;br /&gt;
 			#the first value is x, second one is y&lt;br /&gt;
 &lt;br /&gt;
 eps=40			#define a neighbourhood interpreted as horizontal&lt;br /&gt;
 &lt;br /&gt;
 Default_DISPLAY=&amp;quot;:0.0&amp;quot;&lt;br /&gt;
 Default_XAUTHORITY=/home/smjb0803/.Xauthority&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now lets begin! Just add two ACPI events, first to start the ''x41t_gravity'', second for ending it. &lt;br /&gt;
&lt;br /&gt;
Fist. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-down}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-down&lt;br /&gt;
 # called when tablet head swivels down&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00005009&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh start&lt;br /&gt;
&lt;br /&gt;
Second. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-up}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-up&lt;br /&gt;
 # called when tablet head swivels up&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 0000500a&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh stop&lt;br /&gt;
&lt;br /&gt;
And restart the ACPID.&lt;br /&gt;
  sudo /etc/init.d/acpid restart&lt;br /&gt;
&lt;br /&gt;
That`s it. Have fun and make suggestions. Please use it only if you trust in it. On personal risk. Prevent lost data  yourselves. &lt;br /&gt;
--[[User:Jonasbergel|Jonasbergel]] 09:27, 16 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Jonasbergel</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=39117</id>
		<title>How to rotate X41t screen with gravity sensor(hdaps)</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=39117"/>
		<updated>2008-10-16T13:00:20Z</updated>

		<summary type="html">&lt;p&gt;Jonasbergel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[:Category:X41 Tablet|X41 Tablet]][[Category:X41 Tablet]][[Category:Scripts]]&lt;br /&gt;
&lt;br /&gt;
The X41t has a acceleration sensor build in. Originally it can protect the hard drive, if Laptop is falling down. See the [[HDAPS]] Page.&lt;br /&gt;
Now lets use that for funny stuff like emulate a joystick for Neverball [http://de.wikipedia.org/wiki/Neverball]. Or we use it for a very useful thing: Rotating the screen by recognizing where is downward. Like a lot of handy tools, like mobiles, mp3 player or photo cameras.&lt;br /&gt;
&lt;br /&gt;
 Basic concept is the following: &lt;br /&gt;
 -Rotate the screen and the stylus to the steepest decent direction.&lt;br /&gt;
 -Rotate only in stylus mode.&lt;br /&gt;
 -Rotate only if it is really necessary.&lt;br /&gt;
 -Rotate only if it cants more than 10 degrees.&lt;br /&gt;
 -An easy program.&lt;br /&gt;
&lt;br /&gt;
There are other programs witch can do that, but I have not found one that works out off the box. And I can not understand that much ''python''. So I tried it out myself.&lt;br /&gt;
I have written a set of small ''shell'' scripts that rotates the screen of the X41 Tablet by using the gravity sensor coordinates and some ACPI events.&lt;br /&gt;
It consist of two parts, fist the main part that contains the code for deciding and rotating and the second part which starts and stops the fist one. Maybe some one can make suggestions to get this in a real deamon style. &lt;br /&gt;
&lt;br /&gt;
I have tested it on an x41t with ubuntu 8.04 with the standard kernel 2.6.24-19-generic.&lt;br /&gt;
 ''sudo apt-get install xset x11-xserver-utils wacom-tools'' should install all stuff.&lt;br /&gt;
&lt;br /&gt;
First Part. Usually this is saved as {{path|/etc/acpid/x41t_gravity}}&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
  &lt;br /&gt;
 #usage: just start or kill it&lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 get_orientation(){&lt;br /&gt;
     string=`cat /sys/devices/platform/hdaps/position`&lt;br /&gt;
     string=`echo $string | tr -d '[=-=][:blank:][=(=][=)=]'`&lt;br /&gt;
     x=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $1}'`&lt;br /&gt;
     y=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $2}'`&lt;br /&gt;
     dx=`expr $x - $x_horizontal`		#dx away from middle&lt;br /&gt;
     dy=`expr $y - $y_horizontal`		#dy away form the middle&lt;br /&gt;
     &lt;br /&gt;
      #get actual orientation from last rotation, saved in a file :&lt;br /&gt;
     if [ ! -f /tmp/actual_orientation.txt ];then&lt;br /&gt;
     	echo 0 &amp;gt; /tmp/actual_orientation.txt		#0 means normal orientation&lt;br /&gt;
     fi&lt;br /&gt;
     actual_orientation=`cat /tmp/actual_orientation.txt`&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prepare_rotate(){&lt;br /&gt;
             echo &amp;quot;Nothing to prepare. I can rotate now.&amp;quot;&lt;br /&gt;
 	    #ps -A | grep compiz.real &amp;amp;&amp;amp; (kwin --replace)&amp;amp;	#because compiz sometimes crashes. &lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
 do_rotate(){&lt;br /&gt;
 	    prepare_rotate&lt;br /&gt;
 	    #rotate screen&lt;br /&gt;
 	    xrandr -o $1&lt;br /&gt;
 	    #rotate stylus&lt;br /&gt;
  	    case $1 in&lt;br /&gt;
     		right)&lt;br /&gt;
     		    /usr/bin/xsetwacom set stylus rotate 1;;&lt;br /&gt;
 		left)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 2;;&lt;br /&gt;
 		inverted)	&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 3;;&lt;br /&gt;
     		*)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 0;;&lt;br /&gt;
 	    esac&lt;br /&gt;
 	    #save the orientation			&lt;br /&gt;
 	    echo $1 &amp;gt; /tmp/actual_orientation.txt&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ######### Main ########################&lt;br /&gt;
 &lt;br /&gt;
 while [ true ]; do&lt;br /&gt;
     get_orientation    &lt;br /&gt;
      if [ `expr $dx \* $dx` -ge `expr $dy \* $dy` ];then #checks for the absolute greater value &lt;br /&gt;
  	if [ $dx -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = right ] ;then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate right&lt;br /&gt;
 	elif [ $dx -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = left ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate left&lt;br /&gt;
 	fi&lt;br /&gt;
     else&lt;br /&gt;
 	if [ $dy -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = normal ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate normal&lt;br /&gt;
 	elif [ $dy -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = inverted ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate inverted&lt;br /&gt;
 	fi&lt;br /&gt;
     fi&lt;br /&gt;
     sleep 1&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Second Part. Usually this is saved as {{path|/etc/acpid/x41t_control_gravity.sh}}&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 ################ set DISPLAY ####################&lt;br /&gt;
 export DISPLAY=$Default_DISPLAY		#a work around for right DISPLAY varialbe (I do not like it).&lt;br /&gt;
 export XAUTHORITY=$Default_XAUTHORITY&lt;br /&gt;
 xset -display $DISPLAY dpms&lt;br /&gt;
&lt;br /&gt;
 ################# Main ##########################&lt;br /&gt;
 &lt;br /&gt;
 if [ ! $1 ] || [ ! $1 = start ];then&lt;br /&gt;
     killall x41t_gravity		#return to normal state&lt;br /&gt;
     xrandr -o normal &lt;br /&gt;
     /usr/bin/xsetwacom set stylus rotate 0&lt;br /&gt;
     rm /tmp/actual_orientation.txt&lt;br /&gt;
 elif [ $1 = start ];then&lt;br /&gt;
     #check for the kernel modul for gyroscope&lt;br /&gt;
     lsmod | grep hdaps || modprobe hdaps&lt;br /&gt;
     lsmod | grep hdaps || exit 1&lt;br /&gt;
     (/etc/acpi/x41t_gravity)&amp;amp;		#will be endless repeated (kill see up)&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
Some settings that have to tune. Usually this is saved as {{path|/etc/gravity/gravity.conf}}&lt;br /&gt;
&lt;br /&gt;
 x_horizontal=433	#horizontal position, get it by calibration&lt;br /&gt;
 y_horizontal=390	#just read the value in /sys/devices/platform/hdaps/position&lt;br /&gt;
 			#the first value is x, second one is y&lt;br /&gt;
 &lt;br /&gt;
 eps=40			#define a neighbourhood interpreted as horizontal&lt;br /&gt;
 &lt;br /&gt;
 Default_DISPLAY=&amp;quot;:0.0&amp;quot;&lt;br /&gt;
 Default_XAUTHORITY=/home/smjb0803/.Xauthority&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now lets begin! Just add two ACPI events, first to start the ''x41t_gravity'', second for ending it. &lt;br /&gt;
&lt;br /&gt;
Fist. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-down}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-down&lt;br /&gt;
 # called when tablet head swivels down&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00005009&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh start&lt;br /&gt;
&lt;br /&gt;
Second. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-up}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-up&lt;br /&gt;
 # called when tablet head swivels up&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 0000500a&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh stop&lt;br /&gt;
&lt;br /&gt;
And restart the ACPID.&lt;br /&gt;
  sudo /etc/init.d/acpid restart&lt;br /&gt;
&lt;br /&gt;
That`s it. Have fun and make suggestions. Please use it only if you trust in it. On personal risk. Prevent lost data  yourselves. &lt;br /&gt;
--[[User:Jonasbergel|Jonasbergel]] 09:27, 16 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Jonasbergel</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=39116</id>
		<title>How to rotate X41t screen with gravity sensor(hdaps)</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=39116"/>
		<updated>2008-10-16T12:15:29Z</updated>

		<summary type="html">&lt;p&gt;Jonasbergel: How to rotate X41t screen with gravity sensor&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[:Category:X41 Tablet|X41 Tablet]][[Category:X41 Tablet]][[Category:Scripts]]&lt;br /&gt;
&lt;br /&gt;
The X41t has a acceleration sensor build in. Originally it can protect the hard drive, if Laptop is falling down. See the [[HDAPS]] Page.&lt;br /&gt;
Now lets use that for funny stuff like emulate a joystick for Neverball [http://de.wikipedia.org/wiki/Neverball]. Or we use it for a very useful thing: Rotating the screen by recognizing where is downward. Like a lot of handy tools, like mobiles, mp3 player or photo cameras.&lt;br /&gt;
&lt;br /&gt;
 Basic concept is the following: &lt;br /&gt;
 -Rotate the screen and the stylus to the steepest decent direction.&lt;br /&gt;
 -Rotate only in stylus mode.&lt;br /&gt;
 -Rotate only if it is really necessary.&lt;br /&gt;
 -Rotate only if it cants more than 10 degrees.&lt;br /&gt;
 -An easy program.&lt;br /&gt;
&lt;br /&gt;
There are other programs witch can do that, but I have not found one that works out off the box. And I can not understand that much ''python''. So I tried it out myself.&lt;br /&gt;
I have written a set of small ''shell'' scripts that rotates the screen of the X41 Tablet by using the gravity sensor coordinates and some ACPI events.&lt;br /&gt;
It consist of two parts, fist the main part that contains the code for deciding and rotating and the second part which starts and stops the fist one. Maybe some one can make suggestions to get this in a real deamon style. &lt;br /&gt;
&lt;br /&gt;
I have tested it on an x41t with ubuntu 8.04 with the standard kernel 2.6.24-19-generic.&lt;br /&gt;
 ''sudo apt-get install xset x11-xserver-utils wacom-tools'' should install all stuff.&lt;br /&gt;
&lt;br /&gt;
First Part. Usually this is saved as {{path|/etc/acpid/x41t_gravity}}&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
  &lt;br /&gt;
 #usage: just start or kill it&lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 get_orientation(){&lt;br /&gt;
     string=`cat /sys/devices/platform/hdaps/position`&lt;br /&gt;
     string=`echo $string | tr -d '[=-=][:blank:][=(=][=)=]'`&lt;br /&gt;
     x=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $1}'`&lt;br /&gt;
     y=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $2}'`&lt;br /&gt;
     dx=`expr $x - $x_horizontal`		#dx away from middle&lt;br /&gt;
     dy=`expr $y - $y_horizontal`		#dy away form the middle&lt;br /&gt;
     &lt;br /&gt;
      #get actual orientation from last rotation, saved in a file :&lt;br /&gt;
     if [ ! -f /tmp/actual_orientation.txt ];then&lt;br /&gt;
     	echo 0 &amp;gt; /tmp/actual_orientation.txt		#0 means normal orientation&lt;br /&gt;
     fi&lt;br /&gt;
     actual_orientation=`cat /tmp/actual_orientation.txt`&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prepare_rotate(){&lt;br /&gt;
             echo &amp;quot;Nothing to prepare. I can rotate now.&amp;quot;&lt;br /&gt;
 	    #ps -A | grep compiz.real &amp;amp;&amp;amp; (kwin --replace)&amp;amp;	#because compiz sometimes crashes. &lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
 do_rotate(){&lt;br /&gt;
 	    prepare_rotate&lt;br /&gt;
 	    #rotate screen&lt;br /&gt;
 	    xrandr -o $1&lt;br /&gt;
 	    #rotate stylus&lt;br /&gt;
  	    case $1 in&lt;br /&gt;
     		right)&lt;br /&gt;
     		    /usr/bin/xsetwacom set stylus rotate 1;;&lt;br /&gt;
 		left)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 2;;&lt;br /&gt;
 		inverted)	&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 3;;&lt;br /&gt;
     		*)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 0;;&lt;br /&gt;
 	    esac&lt;br /&gt;
 	    #save the orientation			&lt;br /&gt;
 	    echo $1 &amp;gt; /tmp/actual_orientation.txt&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ######### Main ########################&lt;br /&gt;
 &lt;br /&gt;
 while [ true ]; do&lt;br /&gt;
     get_orientation    &lt;br /&gt;
      if [ `expr $dx \* $dx` -ge `expr $dy \* $dy` ];then #checks for the absolute greater value &lt;br /&gt;
  	if [ $dx -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = right ] ;then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate right&lt;br /&gt;
 	elif [ $dx -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = left ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate left&lt;br /&gt;
 	fi&lt;br /&gt;
     else&lt;br /&gt;
 	if [ $dy -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = normal ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate normal&lt;br /&gt;
 	elif [ $dy -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = inverted ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate inverted&lt;br /&gt;
 	fi&lt;br /&gt;
     fi&lt;br /&gt;
     sleep 1&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Second Part. Usually this is saved as {{path|/etc/acpid/x41t_control_gravity.sh}}&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 ################ set DISPLAY ####################&lt;br /&gt;
 export DISPLAY=$Default_DISPLAY		#a work around for right DISPLAY varialbe (I do not like it).&lt;br /&gt;
 export XAUTHORITY=$Default_XAUTHORITY&lt;br /&gt;
 xset -display $DISPLAY dpms&lt;br /&gt;
&lt;br /&gt;
 ################# Main ##########################&lt;br /&gt;
 &lt;br /&gt;
 if [ ! $1 ] || [ ! $1 = start ];then&lt;br /&gt;
     killall x41t_gravity		#return to normal state&lt;br /&gt;
     xrandr -o normal &lt;br /&gt;
     /usr/bin/xsetwacom set stylus rotate 0&lt;br /&gt;
     rm /tmp/actual_orientation.txt&lt;br /&gt;
 elif [ $1 = start ];then&lt;br /&gt;
     #check for the kernel modul for gyroscope&lt;br /&gt;
     lsmod | grep hdaps || modprobe hdaps&lt;br /&gt;
     lsmod | grep hdaps || exit 1&lt;br /&gt;
     (/etc/acpi/x41t_gravity)&amp;amp;		#will be endless repeated (kill see up)&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
Some settings that have to tune. Usually this is saved as {{path|/etc/gravity/gravity.conf}}&lt;br /&gt;
&lt;br /&gt;
 x_horizontal=433	#horizontal position, get it by calibration&lt;br /&gt;
 y_horizontal=390	#just read the value in /sys/devices/platform/hdaps/position&lt;br /&gt;
 			#the first value is x, second one is y&lt;br /&gt;
 &lt;br /&gt;
 eps=40			#define a neighbourhood interpreted as horizontal&lt;br /&gt;
 &lt;br /&gt;
 Default_DISPLAY=&amp;quot;:0.0&amp;quot;&lt;br /&gt;
 Default_XAUTHORITY=/home/smjb0803/.Xauthority&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now lets begin! Just add two ACPI events, first to start the ''x41t_gravity'', second for ending it. &lt;br /&gt;
&lt;br /&gt;
Fist. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-down}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-down&lt;br /&gt;
 # called when tablet head swivels down&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00005009&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh start&lt;br /&gt;
&lt;br /&gt;
Second. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-up}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-up&lt;br /&gt;
 # called when tablet head swivels up&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 0000500a&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh stop&lt;br /&gt;
&lt;br /&gt;
And restart the ACPID.&lt;br /&gt;
  sudo /etc/init.d/acpid restart&lt;br /&gt;
&lt;br /&gt;
That`s it. Have fun and make suggestions.&lt;br /&gt;
--[[User:Jonasbergel|Jonasbergel]] 09:27, 16 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Jonasbergel</name></author>
		
	</entry>
	<entry>
		<id>https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=39112</id>
		<title>How to rotate X41t screen with gravity sensor(hdaps)</title>
		<link rel="alternate" type="text/html" href="https://www.thinkwiki.org/w/index.php?title=How_to_rotate_X41t_screen_with_gravity_sensor(hdaps)&amp;diff=39112"/>
		<updated>2008-10-16T07:27:19Z</updated>

		<summary type="html">&lt;p&gt;Jonasbergel: â†Created page with 'X41 TabletCategory:X41 Tablet  The X41t has a acceleration sensor build in. Originally it can protect the hard drive, if Laptop is falling dow...'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[:Category:X41 Tablet|X41 Tablet]][[Category:X41 Tablet]]&lt;br /&gt;
&lt;br /&gt;
The X41t has a acceleration sensor build in. Originally it can protect the hard drive, if Laptop is falling down. See the [[HDAPS]] Page.&lt;br /&gt;
Now lets use that for funny stuff like emulate a joystick for Neverball [http://de.wikipedia.org/wiki/Neverball]. Or we use it for a very useful thing: Rotating the screen by recognizing where is downward. Like a lot of handy tools, like mobiles, mp3 player or photo cameras.&lt;br /&gt;
&lt;br /&gt;
 Basic concept is the following: &lt;br /&gt;
 -Rotate the screen and the stylus to the steepest decent direction.&lt;br /&gt;
 -Rotate only in stylus mode.&lt;br /&gt;
 -Rotate only if it is really necessary.&lt;br /&gt;
 -Rotate only if it cants more than 10 degrees.&lt;br /&gt;
 -An easy program.&lt;br /&gt;
&lt;br /&gt;
There are other programs witch can do that, but I have not found one that works out off the box. And I can not understand that much ''python''. So I tried it out myself.&lt;br /&gt;
I have written a set of small ''shell'' scripts that rotates the screen of the X41 Tablet by using the gravity sensor coordinates and some ACPI events.&lt;br /&gt;
It consist of two parts, fist the main part that contains the code for deciding and rotating and the second part which starts and stops the fist one. Maybe some one can make suggestions to get this in a real deamon style. &lt;br /&gt;
&lt;br /&gt;
I have tested it on an x41t with ubuntu 8.04 with the standard kernel 2.6.24-19-generic.&lt;br /&gt;
 ''sudo apt-get install xset x11-xserver-utils wacom-tools'' should install all stuff.&lt;br /&gt;
&lt;br /&gt;
First Part. Usually this is saved as {{path|/etc/acpid/x41t_gravity}}&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
  &lt;br /&gt;
 #usage: just start or kill it&lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 get_orientation(){&lt;br /&gt;
     string=`cat /sys/devices/platform/hdaps/position`&lt;br /&gt;
     string=`echo $string | tr -d '[=-=][:blank:][=(=][=)=]'`&lt;br /&gt;
     x=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $1}'`&lt;br /&gt;
     y=`echo $string | awk -v FS=&amp;quot;,&amp;quot; '{print $2}'`&lt;br /&gt;
     dx=`expr $x - $x_horizontal`		#dx away from middle&lt;br /&gt;
     dy=`expr $y - $y_horizontal`		#dy away form the middle&lt;br /&gt;
     &lt;br /&gt;
      #get actual orientation from last rotation, saved in a file :&lt;br /&gt;
     if [ ! -f /tmp/actual_orientation.txt ];then&lt;br /&gt;
     	echo 0 &amp;gt; /tmp/actual_orientation.txt		#0 means normal orientation&lt;br /&gt;
     fi&lt;br /&gt;
     actual_orientation=`cat /tmp/actual_orientation.txt`&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 prepare_rotate(){&lt;br /&gt;
             echo &amp;quot;Nothing to prepare. I can rotate now.&amp;quot;&lt;br /&gt;
 	    #ps -A | grep compiz.real &amp;amp;&amp;amp; (kwin --replace)&amp;amp;	#because compiz sometimes crashes. &lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
 do_rotate(){&lt;br /&gt;
 	    prepare_rotate&lt;br /&gt;
 	    #rotate screen&lt;br /&gt;
 	    xrandr -o $1&lt;br /&gt;
 	    #rotate stylus&lt;br /&gt;
  	    case $1 in&lt;br /&gt;
     		right)&lt;br /&gt;
     		    /usr/bin/xsetwacom set stylus rotate 1;;&lt;br /&gt;
 		left)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 2;;&lt;br /&gt;
 		inverted)	&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 3;;&lt;br /&gt;
     		*)&lt;br /&gt;
 		    /usr/bin/xsetwacom set stylus rotate 0;;&lt;br /&gt;
 	    esac&lt;br /&gt;
 	    #save the orientation			&lt;br /&gt;
 	    echo $1 &amp;gt; /tmp/actual_orientation.txt&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 ######### Main ########################&lt;br /&gt;
 &lt;br /&gt;
 while [ true ]; do&lt;br /&gt;
     get_orientation    &lt;br /&gt;
      if [ `expr $dx \* $dx` -ge `expr $dy \* $dy` ];then #checks for the absolute greater value &lt;br /&gt;
  	if [ $dx -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = right ] ;then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate right&lt;br /&gt;
 	elif [ $dx -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = left ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate left&lt;br /&gt;
 	fi&lt;br /&gt;
     else&lt;br /&gt;
 	if [ $dy -gt $eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = normal ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate normal&lt;br /&gt;
 	elif [ $dy -lt -$eps ] &amp;amp;&amp;amp; [ ! $actual_orientation = inverted ];then #check if the screen have to rotate&lt;br /&gt;
 	    do_rotate inverted&lt;br /&gt;
 	fi&lt;br /&gt;
     fi&lt;br /&gt;
     sleep 1&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Second Part. Usually this is saved as {{path|/etc/acpid/x41t_control_gravity.sh}}&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 &lt;br /&gt;
 #load configuration&lt;br /&gt;
 . /etc/gravity/gravity.conf&lt;br /&gt;
 &lt;br /&gt;
 ################ set DISPLAY ####################&lt;br /&gt;
 export DISPLAY=$Default_DISPLAY		#a work around for right DISPLAY varialbe (I do not like it).&lt;br /&gt;
 export XAUTHORITY=$Default_XAUTHORITY&lt;br /&gt;
 xset -display $DISPLAY dpms&lt;br /&gt;
&lt;br /&gt;
 ################# Main ##########################&lt;br /&gt;
 &lt;br /&gt;
 if [ ! $1 ] || [ ! $1 = start ];then&lt;br /&gt;
     killall x41t_gravity		#return to normal state&lt;br /&gt;
     xrandr -o normal &lt;br /&gt;
     /usr/bin/xsetwacom set stylus rotate 0&lt;br /&gt;
     rm /tmp/actual_orientation.txt&lt;br /&gt;
 elif [ $1 = start ];then&lt;br /&gt;
     #check for the kernel modul for gyroscope&lt;br /&gt;
     lsmod | grep hdaps || modprobe hdaps&lt;br /&gt;
     lsmod | grep hdaps || exit 1&lt;br /&gt;
     (/etc/acpi/x41t_gravity)&amp;amp;		#will be endless repeated (kill see up)&lt;br /&gt;
 fi&lt;br /&gt;
 &lt;br /&gt;
 exit 0&lt;br /&gt;
&lt;br /&gt;
Some settings that have to tune. Usually this is saved as {{path|/etc/gravity/gravity.conf}}&lt;br /&gt;
&lt;br /&gt;
 x_horizontal=433	#horizontal position, get it by calibration&lt;br /&gt;
 y_horizontal=390	#just read the value in /sys/devices/platform/hdaps/position&lt;br /&gt;
 			#the first value is x, second one is y&lt;br /&gt;
 &lt;br /&gt;
 eps=40			#define a neighbourhood interpreted as horizontal&lt;br /&gt;
 &lt;br /&gt;
 Default_DISPLAY=&amp;quot;:0.0&amp;quot;&lt;br /&gt;
 Default_XAUTHORITY=/home/smjb0803/.Xauthority&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now lets begin! Just add two ACPI events, first to start the ''x41t_gravity'', second for ending it. &lt;br /&gt;
&lt;br /&gt;
Fist. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-down}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-down&lt;br /&gt;
 # called when tablet head swivels down&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 00005009&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh start&lt;br /&gt;
&lt;br /&gt;
Second. Usually this is saved as {{path|/etc/acpi/events/x41t-swivel-up}}.&lt;br /&gt;
 # /etc/acpi/events/x41t-swivel-up&lt;br /&gt;
 # called when tablet head swivels up&lt;br /&gt;
 event=ibm/hotkey HKEY 00000080 0000500a&lt;br /&gt;
 action=/etc/acpi/x41t_control_gravity.sh stop&lt;br /&gt;
&lt;br /&gt;
And restart the ACPID.&lt;br /&gt;
  sudo /etc/init.d/acpid restart&lt;br /&gt;
&lt;br /&gt;
That`s it. Have fun and make suggestions.&lt;br /&gt;
--[[User:Jonasbergel|Jonasbergel]] 09:27, 16 October 2008 (CEST)&lt;/div&gt;</summary>
		<author><name>Jonasbergel</name></author>
		
	</entry>
</feed>