Diff for "X61T"


Differences between revisions 21 and 23 (spanning 2 versions)
Revision 21 as of 2009-10-20 03:54:04
Size: 12930
Editor: emc-voyager2
Comment:
Revision 23 as of 2009-10-22 18:36:06
Size: 7846
Editor: 192
Comment:
Deletions are marked like this. Additions are marked like this.
Line 114: Line 114:
No Solution Yet.
== Creating Rotation Commands ==

Every time the rotation changes we need to change:
1. Display Orientation
2. Wacom Tablet Orientation
3. Left, Right, Up, and Down Tablet Buttons

To do this we will create scripts to do all of this at once

Create a file called /usr/bin/rotatenormal
{{{
sudo gedit /usr/bin/rotatenormal
}}}

And fill it with:
{{{
xrandr -o normal
xsetwacom set stylus Rotate none
sudo setkeycodes 0x71 103 0x6f 108 0x6e 105 0x6d 106
}}}

Then create a file called /usr/bin/rotateright
{{{
sudo gedit /usr/bin/rotateright
}}}

And fill it with:
{{{
xrandr -o right
xsetwacom set stylus Rotate cw
sudo setkeycodes 0x71 105 0x6f 106 0x6e 108 0x6d 103
}}}

Then create a file called /usr/bin/rotateinverted
{{{
sudo gedit /usr/bin/rotateinverted
}}}

And fill it with:
{{{
xrandr -o inverted
xsetwacom set stylus Rotate half
sudo setkeycodes 0x71 108 0x6f 103 0x6e 106 0x6d 105
}}}

Then create a file called /usr/bin/rotateleft
{{{
sudo gedit /usr/bin/rotateleft
}}}

And fill it with:
{{{
xrandr -o left
xsetwacom set stylus Rotate ccw
sudo setkeycodes 0x71 106 0x6f 105 0x6e 103 0x6d 108
}}}

Next we need to add a sudo exception so the user can run the setkeycodes in the script
Type:
{{{
sudo visudo
}}}

Go to the bottom and add
{{{
<username> ALL=NOPASSWD: /usr/bin/setkeycodes
}}}

Where <username> is the username of the user we are enabling rotate for. Repeat this line for all users you wish to permit, or add a group by replacing <username> with %<groupname> where <groupname> is the name of the group you would like to add.

Now the you should be able to type rotatenormal, rotateright, rotateleft, and rotateinverted into terminal and the screen should rotate correctly.

== Enabling the Button ==
Coming soon!
Line 148: Line 222:
..........................THIS SECTION NOT YET UPDATED FOR 9.10......................
The following instructions will allow you to set up automatic screen rotation on the X61t. It only defines the positions of standard laptop and right-hand tablet. Feel free to edit the script to make it more versatile. It should be noted that rotation is not as simple as changing the output orientation of the screen, the pen and tablet navigation buttons need adjustment as well.

Edit rc.local:
{{{
sudo gedit /etc/rc.local
}}}
Add the following before the "exit 0" line:
{{{
setkeycodes 6f 108
setkeycodes 71 103
setkeycodes 6e 105
setkeycodes 6d 106
}}}
Create a file rotate in /usr/local/bin:
{{{
sudo gedit /usr/local/bin/rotate
}}}
with the following content:
{{{
"#!/usr/bin/python" -this is the first line (without quotes) the page will not show it right
}}}

{{{
import os, sys, re

  # All allowed rotations
rotations = ['normal', 'right', 'inverted', 'left']

  # Keyboard scan codes for arrow keys
scanCodes = {'up': 0x71, 'dn': 0x6f, 'lt': 0x6e, 'rt': 0x6d}

  # Keycodes to use for each rotation
  # 104 = pgup, 109 = pgdn, 105 = left, 106 = right, 103 = up, 108 = down
keyCodes = {
            'normal': {'up': 103, 'dn': 108, 'lt': 105, 'rt': 106},
            'right': {'up': 105, 'dn': 106, 'lt': 108, 'rt': 103},
            'inverted': {'up': 108, 'dn': 103, 'lt': 106, 'rt': 105},
            'left': {'up': 106, 'dn': 105, 'lt': 103, 'rt': 108}
          }

  # Rotations to pick from when no specific rotation is given
preferredRotations = rotations

  # Rotation to use when switched to tablet mode
tabletMode = "right"
  
  # Tells the program to stay open when in tablet mode and
  # rotate using the orientation sensor
tabletAutoRotate = True
  
  # Rotation to use when switched to normal laptop mode
laptopMode = "normal"


## If a local xsetwacom is installed, it should probably take precedent (?)
if os.path.isfile('/usr/local/bin/xsetwacom'):
  xsetwacom = '/usr/local/bin/xsetwacom'
elif os.path.isfile('/usr/bin/xsetwacom'):
  xsetwacom = '/usr/bin/xsetwacom'
else:
  ## If it's not one of those two, just hope it's in the path somewhere.
  xsetwacom = 'xsetwacom'

xrandr = '/usr/bin/xrandr'



def main():
  setEnv()
  
    # list of wacom devices to be rotated
  devices = listDevices()
  
  if len(sys.argv) < 2: # No rotation specified, just go to the next one in the preferred list
    cr = getCurrentRotation()
    if cr in preferredRotations:
      nextIndex = (preferredRotations.index(cr) + 1) % len(preferredRotations)
    else:
      nextIndex = 0
    next = preferredRotations[nextIndex]
  else:
    next = sys.argv[1]
    if not next in rotations:
      if next == "tablet":
        next = tabletMode
      elif next == "laptop":
        next = laptopMode
      else:
        sys.stderr.write("Rotation \"%s\" not allowed (pick from %s, tablet, laptop)\n" % (next, ', '.join(rotations)))
        sys.exit(-1)
  setRotation(next, devices)



def runCmd(cmd):
  f = os.popen(cmd)
  l = f.readlines()
  f.close()
  return l

def getCurrentRotation():
  #setEnv()
  try:
    rrv = randrVersion()
    if rrv < '1.2':
      l = [s for s in runCmd(xrandr) if re.match('Current rotation', s)]
      r = re.sub('Current rotation - ', '', l[0])
      return r.strip()
    elif rrv >= '1.2':
      l = runCmd(xrandr) #"%s | grep 'LVDS connected' | gawk '{print $4}' | sed -e 's/(//'" % xrandr)
      l = [x for x in l if re.search(r'(LVDS|default) connected', x)][0]
      l = l.split(' ')[3]
      l = re.sub(r'\(', '', l)
      
      return l.strip()
  except:
    sys.stderr.write("Can not determine current rotation, bailing out :(")
    sys.exit(-1)

def setRotation(o, devices):
  #setEnv()
  runCmd("%s --output LVDS --rotate %s" % (xrandr, o))
  wacomRots = {'normal': '0', 'left': '2', 'right': '1', 'inverted': '3'}
  for d in devices:
    runCmd("%s set %s Rotate %s" % (xsetwacom, d, wacomRots[o]))
  setKeymap(o)

def setEnv():
  if os.environ.has_key('DISPLAY'):
    return # DISPLAY is already set, don't mess with it.
  
  if os.system('pidof kdm > /dev/null') == 0:
    kdmsts = '/var/lib/kdm/kdmsts'
    if os.access(kdmsts, os.R_OK):
      kdmdata = open(kdmsts).readlines()
      userline = [s for s in kdmdata if re.match(r':0=', s)][0]
      user = re.sub(r':0=', '', userline).strip()
      os.environ['DISPLAY'] = ':0.0'
      os.environ['XAUTHORITY'] = '/home/%s/.Xauthority' % user
  elif os.system('pidof gdm > /dev/null') == 0:
    os.environ['DISPLAY'] = ':0.0'
    os.environ['XAUTHORITY'] = '/var/lib/gdm/:0.Xauth'
  
def setKeymap(o):
  for sc in scanCodes.keys():
    os.system('sudo setkeycodes %x %d' % (scanCodes[sc], keyCodes[o][sc]))


def randrVersion():
  #setEnv()
  xrv = runCmd('%s -v' % xrandr)[0]
  xrv = re.sub(r'.*version ', '', xrv)
  return xrv.strip()

def listDevices():
  #setEnv()
  dev = runCmd("%s list dev | awk {'print $1'}" % xsetwacom)
  dev = map(lambda s: s.strip(), dev)
  return dev
   
main()
}}}
Change the files permissions to 755:
{{{
sudo chmod 755 /usr/local/bin/rotate
}}}

Run visudo and add the following line to the bottom:
{{{
%admin ALL=NOPASSWD: /usr/bin/setkeycodes
}}}
This allows the setkeycodes command to be run from within the script.

You should now be able to type "rotate tablet" and "rotate laptop" from a command prompt to turn the screen at will. This script also adjust the arrow keypad on the side of the tablet so that the directions correspond to screen directions and sets the tablet pen to move correctly.


=== The Automatic Part ===
Create a directory autorotate in /etc:
{{{
sudo mkdir /etc/autorotate
}}}
Add a file lastrotation to it:
{{{
sudo gedit /etc/autorotate/lastrotation
}}}
Fill it with:
{{{
laptop
}}}
Change its permissions to 666:
{{{
sudo chmod 666 /etc/autorotate/lastrotation
}}}

Create a new file:
sudo gedit /usr/local/bin/autorotate
Fill it with:
{{{
#!/bin/sh

/usr/local/bin/rotate `cat /etc/autorotate/lastrotation`
}}}
Change its permissions to 755:
{{{
sudo chmod 755 /usr/local/bin/autorotate
}}}
Create another file:
{{{
sudo gedit /usr/local/bin/setrotation
}}}
Fill it with:
{{{
#!/bin/sh

echo $1 > /etc/autorotate/lastrotation
/usr/local/bin/autorotate
}}}
Set Permissions to 755:
{{{
sudo chmod 755 /usr/local/bin/setrotation
}}}
Create a file:
{{{
sudo gedit /etc/acpi/events/swivel-up
{{{
Fill it with:
{{{
# called when tablet screen swivels up (into laptop mode)
event=ibm/hotkey HKEY 00000080 0000500a
action=/usr/local/bin/setrotation laptop
}}}
Create a file:
{{{
sudo gedit /etc/acpi/events/swivel-down
}}}
Fill it with:
{{{
# called when tablet screen swivels down (into tablet mode)
event=ibm/hotkey HKEY 00000080 00005009
action=/usr/local/bin/setrotation tablet
}}}
Reboot your system.
Due to changes in the way hotkeys and ACPI function, the former methods for Autorotation are broken. This did function in Jaunty.

Introduction

This page covers the additional hardware setup required after a default installation of Ubuntu 9.10 Karmic Koala to make the Thinkpad X61 Tablet fully functional. All instructions are given avoiding creation of an xorg.conf file.

What Works

Forward / Back Buttons, Audio Buttons, Brightness Fn Buttons, Radio Fn Button, Suspend Fn Button, Power Fn Button, Lock Fn Button, Hibernate Fn Button, Tablet L/R/U/D Buttons, Tablet Enter Button, Tablet Esc Button, Media Fn Buttons NumberLock Fn Button, Tablet Pen, Wireless Radio, Bluetooth Radio,

What Almost Works

Tablet Toolbox Button - causes lock or suspend, Tablet Touch – Requires Calibration,

What Does Not Work

Tablet Control-Alt-Delete Button, Tablet Rotate Button, Middle Mouse Button Scrolling, ThinkVantage Button, Magnify Fn Button, Fingerprint Reader, Automatic Screen Rotation, ThinkVantage ActiveProtection,

Fixing Touch

The Wacom touchscreen works out of the box, but loses accuracy at the edges of the screen. To fix this the touchscreen needs to be calibrated.

Wacomcpl

The Wacom Tablet in the X61t is a serial Wacom tablet. It can be configured by using wacomcpl. Wacomcpl is part of the wacom-tools package and can be retrieved in apt:

sudo apt-get install wacom-tools

After this wacomcpl can be run by typing: wacomcpl in Terminal.

Helping wacomcpl

Unfortunately HAL assigns names to wacom devices in a way that the current wacomcpl cant find them, to help wacomcpl to find them we need to create a rule to rename the outputs as wacomcpl expects.

Open a terminal and type :

sudo gedit /ect/hal/fdi/policy/wacom.fdi

and paste this code in:

<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
  <device>
    <match key="input.x11_driver" contains="wacom">
      <match key="input.x11_options.Type" contains="stylus">
        <merge key="info.product" type="string">stylus</merge>
      </match>
      <match key="input.x11_options.Type" contains="eraser">
         <merge key="info.product" type="string">eraser</merge>
      </match>
      <match key="input.x11_options.Type" contains="touch">
         <merge key="info.product" type="string">touch</merge>
      </match>
    </match>
  </device>
</deviceinfo>

Now reboot and launch wacomcpl. You should now be able to see the devices and calibrate them.

Making Wacomcpl Settings Restore on Reboot

If you lose your calibration after reboot:

In terminal:

sudo gedit ~/.xinitrc

Find the line that says:

. /etc/X11/xinit/xinitrc

and change it to

#. /etc/X11/xinit/xinitrc

Save and exit.

Go to System>Preferences>Startup Applications and create a new entry named whatever you want.

The command should be:

sh /home/yourusername/.xinitrc

Your wacomcpl settings will now restore on reboot

Fixing the Tablet Toolbox Button

No Solution Yet.

Setup the Tablet Control-Alt-Delete Button

No Solution Yet.

Setup the Tablet Rotate Button

Creating Rotation Commands

Every time the rotation changes we need to change: 1. Display Orientation 2. Wacom Tablet Orientation 3. Left, Right, Up, and Down Tablet Buttons

To do this we will create scripts to do all of this at once

Create a file called /usr/bin/rotatenormal

sudo gedit /usr/bin/rotatenormal

And fill it with:

xrandr -o normal
xsetwacom set stylus Rotate none
sudo setkeycodes  0x71 103 0x6f 108 0x6e 105 0x6d 106

Then create a file called /usr/bin/rotateright

sudo gedit /usr/bin/rotateright

And fill it with:

xrandr -o right
xsetwacom set stylus Rotate cw
sudo setkeycodes  0x71 105 0x6f 106 0x6e 108 0x6d 103

Then create a file called /usr/bin/rotateinverted

sudo gedit /usr/bin/rotateinverted

And fill it with:

xrandr -o inverted
xsetwacom set stylus Rotate half
sudo setkeycodes  0x71 108 0x6f 103 0x6e 106 0x6d 105

Then create a file called /usr/bin/rotateleft

sudo gedit /usr/bin/rotateleft

And fill it with:

xrandr -o left
xsetwacom set stylus Rotate ccw
sudo setkeycodes  0x71 106 0x6f 105 0x6e 103 0x6d 108

Next we need to add a sudo exception so the user can run the setkeycodes in the script Type:

sudo visudo

Go to the bottom and add

<username> ALL=NOPASSWD: /usr/bin/setkeycodes

Where <username> is the username of the user we are enabling rotate for. Repeat this line for all users you wish to permit, or add a group by replacing <username> with %<groupname> where <groupname> is the name of the group you would like to add.

Now the you should be able to type rotatenormal, rotateright, rotateleft, and rotateinverted into terminal and the screen should rotate correctly.

Enabling the Button

Coming soon!

Setup the Middle Button Scrolling

Create a new file called /etc/hal/fdi/policy/mouse-wheel.fdi typing:

sudo gedit /etc/hal/fdi/policy/mouse-wheel.fdi

And fill it with this code:

<?xml version="1.0" encoding="UTF-8"?> 

<match key="info.product" string="TPPS/2 IBM TrackPoint">
 <merge key="input.x11_options.EmulateWheel" type="string">true</merge>
 <merge key="input.x11_options.EmulateWheelButton" type="string">2</merge>
 <merge key="input.x11_options.XAxisMapping" type="string">6 7</merge>
 <merge key="input.x11_options.YAxisMapping" type="string">4 5</merge>
 <merge key="input.x11_options.ZAxsisMapping" type="string">4 5</merge>
 <merge key="input.x11_options.Emulate3Buttons" type="string">true</merge>
</match>

Reboot

Setup ThinkVantage Button

The ThinkVantage button does not work, only in that it is not bound to anything as there is no ThinkVantage in linux. To bind it go to System>Preferences>Keyboard Shortcuts and set it to perform any command.

Setup Magnify Fn Button

No Solution Yet.

Setup Fingerprint Reader

No Solution Yet.

Setup Automatic Screen Rotation

Due to changes in the way hotkeys and ACPI function, the former methods for Autorotation are broken. This did function in Jaunty.

Setup ThinkVantage ActiveProtection

No Solution Yet.

Useful Task: Enable Laptop Mode

Laptop mode is a power saving tool that allows the hard drive to spin down to conserve battery power. This is disabled by default as it has been known to cause problems on some computers, but it appears to work on the X61t.

*Warning: Laptop mode stores data in ram teporarily until it needs to write to disk. Power Loss in laptop mode could lead to significant data loss.

*Warning: Excessive spin-up spin-down cycles will wear out your hard drive much more quickly than normal use. Be careful when configuring laptop mode settings.

*Warning: Do Not Use Laptop Mode if you have a SSD. It is for platter drives only.

Edit /etc/default/acpi-support

sudo gedit /etc/default/acpi-support

Set: "ENABLE_LAPTOP_MODE=true"

Configure Laptop Mode

sudo gedit /etc/laptop-mode/laptop-mode.conf

More

Feel free to add more to this page. Some solutions may exist on thinkwiki.org

See Also

X61T (last edited 2015-03-30 20:26:54 by knome)