Installing Ubuntu 12.10 on Thinkpad Twist

From ThinkWiki
Revision as of 03:12, 29 January 2013 by Shane (Talk | contribs) (Initial details of my Ubuntu 12.10 install onto the Lenovo Twist)
Jump to: navigation, search
This page is a stub

You can help ThinkWiki by expanding it.

Needs disabling of UEFI in the BIOS setup screens

Touch screen - single touch only

Sound, WLAN, camera, SSD works

WWAN works GPS does not work


DMESG etc to follow

Installing Ubuntu on the Lenovo Twist ultrabook

Specs

  • Lenovo Twist - S230u (model 3347-CTO)
  • Ubuntu 12.10 - 64bit (ubuntu-12.10-desktop-amd64.iso)

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)
Button Purpose HKEY Scan Code Key Code Key Sym Bind To Works Out of Box Works with Tweaking
F1 "Mute" key (toggle speaker muting) unknown unknown 113 unknown unknown yes N/A
F2 "Volume Down" key unknown unknown 114 unknown unknown yes N/A
F3 "Volume Up" key unknown unknown 115 unknown unknown yes N/A
F4 "Mic" key (toggle mic muting) 00000080 0000101b 0x1A micmute unknown /etc/acpi/event/lenovo-micmute
calls amixer to toggle Capture device
no yes
F5 "Brightness Down" key unknown unknown 224 unknown unknown yes N/A
F6 "Brightness Up" key unknown unknown 225 unknown unknown yes N/A
F7 "Display" key (toggle display output selection) unknown 0x06 227 switchvideomode yes N/A
F8 "Radio" key (toggle Airplane mode) unknown unknown unknown unknown unknown yes N/A
F9 "Settings" key (launch settings charm/app) 00000080 0000101d 0x1C unknown unknown gnome-control-center no yes
F10 "Search" key (launch search charm/app) 00000080 0000101e 0x1D unknown unknown Meta-f (Unity file search) no yes
F11 "Task Manager" key (show opened programs) 00000080 0000101f 0x1E unknown unknown Alt-Tab (task switcher) no yes
F12 "All Apps" key (show picker for all installed programs) 00000080 00001020 0x1F unknown unknown Meta no yes
Lid flipped Enable tablet mode 00000080 000060c0
00000080 00005009
unknown reserved unknown Launch on-screen keyboard no yes
Lid normal Disable tablet mode 00000080 000060c0
00000080 0000500a
unknown reserved unknown Hide on-screen-keyboard no yes
Rotate Toggle screen rotation 00000080 00006020 unknown unknown unknown /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

and 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:

Add-custom-keybinding.png

In this example, I tell it to invoke the script ~/toggle-touchpad.sh, which might look something like this:

#!/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)]}

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 path name phys ev flags
/dev/input/event0 Power Button PNP0C0C/button/input0 EV_SYN EV_KEY
/dev/input/event1 Lid Switch PNP0C0D/button/input0 EV_SYN EV_SW
/dev/input/event2 Power Button LNXPWRBN/button/input0 EV_SYN EV_KEY
/dev/input/event3 AT Translated Set 2 keyboard isa0060/serio0/input0 EV_SYN EV_KEY
EV_MSC EV_LED
EV_REP
/dev/input/event4 ThinkPad Extra Buttons thinkpad_acpi/input0 EV_SYN EV_KEY
EV_MSC EV_SW
/dev/input/event5 Atmel Atmel maXTouch Digitizer usb-0000:00:1a.0-1.1/input0 EV_SYN EV_KEY
EV_ABS
/dev/input/event6 Integrated Camera usb-0000:00:1d.0-1.6/button EV_SYN EV_KEY
/dev/input/event7 Video Bus LNXVIDEO/video/input0 EV_SYN EV_KEY
/dev/input/event8 SynPS/2 Synaptics TouchPad isa0060/serio1/input0 EV_SYN EV_KEY
EV_ABS
/dev/input/event9 HDA Intel PCH HDMI/DP,pcm=7 ALSA EV_SYN EV_SW
/dev/input/event10 HDA Intel PCH HDMI/DP,pcm=3 ALSA EV_SYN EV_SW
/dev/input/event11 HDA Intel PCH Mic ALSA EV_SYN EV_SW
/dev/input/event12 HDA Intel PCH Headphone ALSA EV_SYN EV_SW
/dev/input/event13 TPPS/2 IBM TrackPoint synaptics-pt/serio0/input0 EV_SYN EV_KEY
EV_REL