Installing Ubuntu 12.10 on Thinkpad Twist

From ThinkWiki
Jump to navigation Jump to search

Installing Ubuntu 12.10 on the Lenovo Twist ultrabook

Overview

Specs

  • Lenovo Twist - S230u (model 3347-CTO)
  • Ubuntu 12.10 - 64bit (ubuntu-12.10-desktop-amd64.iso)
TODO
DMESG etc to follow

What Works

  • Touch screen - single touch only
    FIXME
    Needs review. Multitouch worked for me --Shane 03:20, 29 January 2013 (CET)
  • Sound, WLAN, camera, SSD works
  • WWAN works

What Does Not Work

  • GPS does not work

Install

ATTENTION!
Since this device ships with the BIOS set to boot from UEFI only. You must enable Legacy boot option in the BIOS before you can begin installing Ubuntu.
  1. Enable Legacy boot in BIOS
  2. Plug in USB drive containing Ubuntu 12.10 install image
  3. Turn power on
  4. Proceed through install
  5. Reboot when done
  6. Log in and install any available updates (rebooting as needed)

Customize

Additional Packages

Much of what follows depends on some additional tools. You can run the following command to install them all at once:

$ sudo apt-get install \
mesa-utils               # resolves "Graphics Unknown" reported in system info \
input-utils              # Misc tools to assist in detecting and configuring special HW keys/events

Graphics

Fix "unknown" graphics adapter

Install mesa-utils, which adds glxinfo, used by system info to report the "friendly" graphics device name $ sudo apt-get install mesa-utils

Enable SNA

To enable SNA (vs. default UXA) in X, create an Xorg config option file (/usr/share/X11/xorg.conf.d/20-enable-sna.conf) as follows:

# cat <<EOF > /usr/share/X11/xorg.conf.d/20-enable-sna.conf
Section "Device"
    Identifier "Card0"
    Driver "intel"
    Option "AccelMethod" "sna"
EndSection
EOF

Key Bindings

Hint:
Lenovo's intended behavior for the Function keys in Windows 8 is defined in the their Lenovo Twist User Manual)
ButtonPurposeHKEYScan CodeKey CodeKey SymBind ToWorks Out of BoxWorks with Tweaking
F1"Mute" key (toggle speaker muting)unknownunknown113unknownunknownyesN/A
F2"Volume Down" keyunknownunknown114unknownunknownyesN/A
F3"Volume Up" keyunknownunknown115unknownunknownyesN/A
F4"Mic" key (toggle mic muting)00000080 0000101b0x1Amicmuteunknown/etc/acpi/event/lenovo-micmute
calls amixer to toggle Capture device
noyes
F5"Brightness Down" keyunknownunknown224unknownunknownyesN/A
F6"Brightness Up" keyunknownunknown225unknownunknownyesN/A
F7"Display" key (toggle display output selection)unknown0x06227switchvideomodeyesN/A
F8"Radio" key (toggle Airplane mode)unknownunknownunknownunknownunknownyesN/A
F9"Settings" key (launch settings charm/app)00000080 0000101d0x1Cunknownunknowngnome-control-centernoyes
F10"Search" key (launch search charm/app)00000080 0000101e0x1DunknownunknownMeta-f (Unity file search)noyes
F11"Task Manager" key (show opened programs)00000080 0000101f0x1EunknownunknownAlt-Tab (task switcher)noyes
F12"All Apps" key (show picker for all installed programs)00000080 000010200x1FunknownunknownMetanoyes
Lid flippedEnable tablet mode00000080 000060c0
00000080 00005009
unknownreservedunknownLaunch on-screen keyboard?
Disable TouchPad/Enable TouchScreen
noyes
Lid normalDisable tablet mode00000080 000060c0
00000080 0000500a
unknownreservedunknownHide on-screen-keyboard?
Enable TouchPad/Disable TouchScreen
noyes
RotateToggle screen rotation00000080 00006020unknownunknownunknown/etc/acpi/event/lenovo-twist-rotate
calls notify-send ATM, since xrandr is crashing X :/
no
FIXME
X crashing

Toggling TouchPad

One of the very annoying things about the available settings in 12.10 is that there no longer appears to be a way to completely disable the Synaptics TouchPad device from the UI. Also, no touchpad indicator applet appears to be available in the standard repos.

Related to this, is the very poor interaction between the TouchPad and the TouchScreen (Atmel maXTouch Digitizer) when the screen is folded into tablet mode. The result is the cursor begins to jump around and get "twitchy".

So, to solve this, there are two things to address:

  1. How to disable/enable the TouchPad on demand (hotkey event or other keybinding)
  2. How to disable/enable the TouchPad automatically when tablet mode is enabled/disabled

On Demand

To add new, custom, key bindings, launch the "Keyboard" editor:

$ gnome-control-center keyboard

Then navigate to the "Shortcuts" tab, select the "Custom Shortcuts" and then click the "+" button and provide the name and command for your binding. For example:

In this example, I tell it to invoke the script ~/toggle-touchpad.sh, which you can create like this:

cat <<EOF > ~/toggle-touchpad.sh
#!/bin/bash
declare -A TOGGLE=([true]=false [false]=true)
SCHEMA="org.gnome.settings-daemon.peripherals.touchpad"
KEY="touchpad-enabled"
gsettings set $SCHEMA $KEY ${TOGGLE[$(gsettings get $SCHEMA $KEY)]}
EOF

Or, use this one-line version directly in the "Command:" field:

/bin/bash -c 'declare -A TOGGLE=([true]=false [false]=true) && \
    SCHEMA="org.gnome.settings-daemon.peripherals.touchpad" && \
    KEY="touchpad-enabled" && \
    gsettings set $SCHEMA $KEY ${TOGGLE[$(gsettings get $SCHEMA $KEY)]}' 

Finally, click the word "disabled" on the newly added custom shortcut and hit the button or key combination you want to use for toggling the TouchPads enabled state.

Automatic

To solve the "jitter" problem with the mouse when the Twist is in tablet mode, a few additions to the acpi events handlers is all that's required. The following need to be run as root, or via sudo.

First, we need to configure acpid to recognize the events triggered when the Twist changes tablet mode state:

cat <<EOF > /etc/acpi/events/twist-tablet-enabled
# /etc/acpi/events/twist-tablet-enabled
# This is called when the lid is placed in tablet position on
# Lenovo Twist ThinkPads

event=ibm/hotkey HKEY 00000080 00005009
action=/etc/acpi/twist-tabletmode.sh 1
EOF

cat <<EOF > /etc/acpi/events/twist-tablet-disabled
# /etc/acpi/events/twist-tablet-disabled
# This is called when the lid is placed in normal position on
# Lenovo Twist ThinkPads

event=ibm/hotkey HKEY 00000080 0000500a
action=/etc/acpi/twist-tabletmode.sh 0
EOF

# Now, restart acpid so it can re-read the event filters, including the ones you just added
killall -SIGHUP acpid

Second, create the referenced action script (/etc/acpi/twist-tabletmode.sh):

cat <<EOF > /etc/acpi/twist-tabletmode.sh
#!/bin/bash
[ -f /usr/share/acpi-support/state-funcs ] || exit 0 

. /usr/share/acpi-support/power-funcs

getXconsole

# If passed in a (valid) arg, use it
[ "$1" ] && [ "$1" = "0" -o "$1" = "1" ] && MODE=${MODE:=${1}}

# Otherwise, use current state from thinkpad acpi sysfs entry, as described at
# http://www.kernel.org/doc/Documentation/laptops/thinkpad-acpi.txt
MODE=${MODE:="$(cat /sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode)"}

TOUCHPAD_NAME="TouchPad"
TOUCHPAD_STATES=("enable" "disable")
TOUCHPAD_CMD=${TOUCHPAD_STATES[$MODE]}

TOUCHSCREEN_NAME="maXTouch"
TOUCHSCREEN_STATES=("disable" "enable")
TOUCHSCREEN_CMD=${TOUCHSCREEN_STATES[$MODE]}

# Get xinput ids for the TouchPad and TouchScreen devices
TOUCHPAD_ID=$(xinput list --id-only "$(xinput list --name-only|grep -m1 $TOUCHPAD_NAME)")
TOUCHSCREEN_ID=$(xinput list --id-only "$(xinput list --name-only|grep -m1 $TOUCHSCREEN_NAME)")
 
# Get users configured TouchPad state preference and honor it.
TOUCHPAD_ENABLED=$(sudo -iu $user gsettings get org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled)
 
# Only change TouchPad state if touchpad-enabled=true and a device was found
[ ${#TOUCHPAD_ID} -gt 0 -a "$TOUCHPAD_ENABLED" = "true" ] && xinput $TOUCHPAD_CMD $TOUCHPAD_ID
 
# Only change TouchScreen state if a device was found
[ ${#TOUCHSCREEN_ID} -gt 0 ] && xinput $TOUCHSCREEN_CMD $TOUCHSCREEN_ID
  
EOF

# Make it executable...
chmod +x /etc/acpi/twist-tabletmode.sh

That's it!!! Time to test it out by converting the Twist into tablet mode. You can crack the lid about 1½ inches before the Twist will exit tablet mode. While in tablet mode, crack the lid and confirm that touching the TouchPad has no effect.

More Detail

Initially, I pursued this as an XInput issue, only to discover later after digging through this to solve the automatice use case during tablet mode changes, that there is a GSettings key that also is at play here. As I soon discovered, the GSettings key will actually determine if any changes vi xinput will be honored.

XInput Method

First, determine the xinput device id for the TouchPad

$ xinput list --name-only
SynPS/2 Synaptics TouchPad

Next, using this name, get the xinput device id for it

$ xinput list --id-only "SynPS/2 Synaptics TouchPad"
12

Now, to disable and then enable it, simply run

$ xinput disable 12
$ xinput enable 12

GSettings Method

There is a GSettings key in the org.gnome.settings-daemon.peripherals.touchpad schema called touchpad-enabled. To get and set this key, you use the gsettings command from a terminal that is associated with your active user session:

Get the current value of touchpad-enabled

$ gsettings get org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled
true

To disable the TouchPad, set touchpad-enabled to false

$ gsettings set org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled false

Now check the value of touchpad-enabled, should be false...

$ gsettings get org.gnome.settings-daemon.peripherals.touchpad touchpad-enabled
false

Think Light Control

You can control red the LED in the "i" of the "ThinkPad" logo as follows

Turn on the LED...

# echo 0 on > /proc/acpi/ibm/led

Turn off the LED...

# echo 0 off > /proc/acpi/ibm/led

Blink the LED

# echo 0 blink > /proc/acpi/ibm/led

Headphone Plug Events

On the Twist, when I was testing this, /dev/input/event12 was where Headphone jack plug and unplug events were being reported

Install the input-utils package and then run:

# input-events 12
/dev/input/event12
   bustype : (null)
   vendor  : 0x0
   product : 0x0
   version : 0
   name    : "HDA Intel PCH Headphone"
   phys    : "ALSA"
   bits ev : EV_SYN EV_SW

waiting for events
11:54:14.257360: EV_SW SW_HEADPHONE_INSERT 1
11:54:14.257361: EV_SYN code=0 value=0
11:54:14.587882: EV_SW SW_HEADPHONE_INSERT 0
11:54:14.587883: EV_SYN code=0 value=0
NOTE!

SW_HEADPHONE_INSERT 1 represents the "plug" event
SW_HEADPHONE_INSERT 0 represents the "unplug" event

Input Mapping

The following table is derived from the output of the # lsinput command (part of the input-utils package)

/dev pathnamephysev flags
/dev/input/event0Power ButtonPNP0C0C/button/input0EV_SYN EV_KEY
/dev/input/event1Lid SwitchPNP0C0D/button/input0EV_SYN EV_SW
/dev/input/event2Power ButtonLNXPWRBN/button/input0EV_SYN EV_KEY
/dev/input/event3AT Translated Set 2 keyboardisa0060/serio0/input0EV_SYN EV_KEY
EV_MSC EV_LED
EV_REP
/dev/input/event4ThinkPad Extra Buttonsthinkpad_acpi/input0EV_SYN EV_KEY
EV_MSC EV_SW
/dev/input/event5Atmel Atmel maXTouch Digitizerusb-0000:00:1a.0-1.1/input0EV_SYN EV_KEY
EV_ABS
/dev/input/event6Integrated Camerausb-0000:00:1d.0-1.6/buttonEV_SYN EV_KEY
/dev/input/event7Video BusLNXVIDEO/video/input0EV_SYN EV_KEY
/dev/input/event8SynPS/2 Synaptics TouchPadisa0060/serio1/input0EV_SYN EV_KEY
EV_ABS
/dev/input/event9HDA Intel PCH HDMI/DP,pcm=7ALSAEV_SYN EV_SW
/dev/input/event10HDA Intel PCH HDMI/DP,pcm=3ALSAEV_SYN EV_SW
/dev/input/event11HDA Intel PCH MicALSAEV_SYN EV_SW
/dev/input/event12HDA Intel PCH HeadphoneALSAEV_SYN EV_SW
/dev/input/event13TPPS/2 IBM TrackPointsynaptics-pt/serio0/input0EV_SYN EV_KEY
EV_REL