Lenovo ThinkPad X1 Carbon (Gen 2)

From ArchWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Tango-edit-clear.pngThis article or section does not follow the Laptop page guidelines.Tango-edit-clear.png

Reason: Needs a hardware table and a function keys section (Discuss in Talk:Lenovo ThinkPad X1 Carbon (Gen 2))

Hardware

Almost everything works out of the box. Most of the hardware is based on the Intel Lynx Point reference design.

Power Management

The kernel module thinkpad_acpi picks up most of the sensors. The kernel module tp_smapi is not currently supported. PCIe ASPM does not currently work.

Udev does not not notify whenever battery discharges by 1%, but it does notify at 80%, 20%, 5%, 4% and 0%. To take advantage of this, see (Suspend On Low Battery Laptop#Hibernate on low battery level)

Wake From Suspend

Wake from suspend can be buggy with earlier versions of the bios, see: [1][dead link 2021-11-13 ⓘ]

This can be solved by flashing the bios to a version >=1.13. Look here for Lenovo's bios versions: [2]

A guide how to make a bootable BIOS key drive can be found here: [3]

And some fairly old help from Lenovo here: [4]

If the function keys fail to wake after suspend, ensure you have a kernel version >=3.15.

If you build your own kernels, make sure to either enable TPM (Trusted Platform Module) drivers or disable the Security Chip in the BIOS.

Keyboard

On kernel 3.14 and lower the adaptive panel at the top of the keyboard is locked to function mode.

From kernel 3.15, Home mode is also available which allows access to screen brightness and other controls.

If you wish to remap keys to get back to a sane keyboard layout, you can use either xmodmap or xkb. The difference is largely user preference.

Remapping keys using xmodmap

To get the tilde key back to a sane location on the keyboard you can use xmodmap Xmodmap to remap Shift-Esc to '~'. Install xorg-xmodmap and generate a custom key map:

$ xmodmap -pke > ~/.Xmodmap

Then edit your key map:

~/.Xmodmap
...
keycode   9 = Escape asciitilde Escape
...

Make sure xmodmap loads your new keymap on login:

~/.xinitrc
...
if [ -s ~/.Xmodmap ]; then
       xmodmap ~/.Xmodmap
fi
...

Remapping keys using xkb

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: This is not the intended usage of XKB, these changes will be lost on every update of xkeyboard-config package which owns the files. (Discuss in Talk:Lenovo ThinkPad X1 Carbon (Gen 2))
Backtick (`) and Tilde (~)

To get the backtick/tilde back to a normal location, add the following definition for the Escape button:

/usr/share/X11/xkb/symbols/pc
key <ESC>  { [ grave, asciitilde ] };
Home and End

You may also wish to remap the 'Home' and 'End' button back to Caps Lock, or Escape. Change the lines for HOME and END as follows:

/usr/share/X11/xkb/symbols/pc
key <HOME> { [ Caps_Lock ] };
key  <END> { [ Caps_Lock ] };

or to make 'Home' and 'End' be Escape:

/usr/share/X11/xkb/symbols/pc
key <HOME> { [ Escape ] };
key  <END> { [ Escape ] };
BackSpace and Delete

If you find yourself accidentally hitting the delete key instead of backspace, you may wish to make both backspace and delete be 'BackSpace', while functioning as 'Delete' when you hold down shift:

/usr/share/X11/xkb/symbols/pc
key <BKSP> { [ BackSpace, Delete ] };
key <DELE> { [ BackSpace, Delete ] };

Trackpad

To enable Trackpad support you need to install xf86-input-synaptics.

Warning: the above did the opposite for me. When both xf86-input-synaptics and xf86-input-libinput are installed, the trackpoint (red thingy) uses libinput by default, so it does not cooperate with the trackpad (which by default is driven by synaptics), and as a result you cannot scroll with middle button + trackpoint. Keeping only xf86-input-libinput got everything working.

Lock-ups on click

There are significant issues with the trackpad locking up on click. This is due to the trackpad operating in buggy PS/2 mode.

One alternative is to abandon the trackpad completely and use the trackpoint. Make sure xf86-input-synaptics is not installed - the trackpad will still register button one mouse clicks. Using xbindkeys Xbindkeys and xdotool, right button clicks can be mapped to some other event. For example:

~/.xbindkeysrc
# Emit a right click on Alt + trackpad click
"xdotool click 3"
  Mod1 + b:1 + Release

Tweaking trackpad behavior

The behavior of the trackpad by default can be contrary to your expectations, particularly if you are coming from an OS X style trackpad. The following settings can help significantly:

/etc/X11/xorg.conf.d/99-x1carbon.conf
# Copy this to /etc/X11/xorg.conf.d/99-x1carbon.conf
 Section "InputClass"
     Identifier "X1 carbon stuff"
     MatchIsTouchpad "on"
     MatchDevicePath "/dev/input/event*"
     Driver "synaptics"

     # Enable two finger scrolling vertically, disable horizontally
     Option "VertTwoFingerScroll" "1"
     Option "HorizTwoFingerScroll" "0"

     # No scrolling along the edge
     Option "VertEdgeScroll" "0"
     Option "HorizEdgeScroll" "0"

     Option "LockedDrags" "0"
     Option "FingerPress" "1"

     # Turn off the blasted corners as buttons
     Option "RTCornerButton" "0"
     Option "RBCornerButton" "0"
     Option "LTCornerButton" "0"
     Option "LBCornerButton" "0"

     # Ignore "taps" and listen for "clicks"
     Option "TapButton1" "0"
     Option "TapButton2" "0"
     Option "TapButton3" "0"
     Option "ClickFinger1" "1" # Left click one finger
     Option "ClickFinger2" "3" # Right click two fingers
     Option "ClickFinger3" "0" # Three finger click disabled

     Option "TapAndDragGesture" "0"

     # No circular scrolling
     Option "CircularScrolling" "0"
 EndSection

If you are using gnome-shell, you may need to tell the settings app not to overwrite our changes:

gsettings set org.gnome.settings-daemon.plugins.mouse active false

Touchpad not working after wake up from sleep

See here: Touchpad Synaptics#Touchpad does not work after resuming from hibernate/suspend

Keyboard backlight

Works out of the box. there is a button on the soft keyboard to toggle it between off, low, and high brightness.

Automatically turn on backlight when typing

Using a c program that continuously checks for keyboard input, it is possible to activate the backlight for a certain time. The program source is as a follows

kbdbacklight.c
/* Original Author: Howard Chu <hyc@symas.com> 2013-01-15
 *
 * compile as "gcc -O2 -o kbdbacklight kbdbacklight.c" and run it in the background, or arrange to have it run at bootup.
 *
 * adapted by gabtub@gmail.com 2017-01-22
 * using https://gist.github.com/hadess/6847281
 * based on http://askubuntu.com/questions/383501/enable-the-keyboard-backlights-on-supported-lenovo-e-g-carbon-x1-with-command
 * original code found at  http://forum.notebookreview.com/threads/asus-keyboard-backlight-controller.703985/
 * sigterm catching done as shown in https://airtower.wordpress.com/2010/06/16/catch-sigterm-exit-gracefully/
 *
 * monitor keyboard activity and toggle keyboard backlight
 */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <poll.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>

static char dummybuf[8192];

/** @brief How many milliseconds before turning off kbd light */
#ifndef IDLE_MSEC
#define IDLE_MSEC	5000
#endif

#ifndef BRGHT_OFF
#define BRGHT_OFF	3
#endif
#ifndef BRGHT_MED
#define BRGHT_MED 67
#endif
#ifndef BRGHT_MAX
#define BRGHT_MAX 131
#endif

volatile sig_atomic_t running = 1;

void term(int signum)
{
    // sigterm == 15
    running = 0;
}

int main(int argc, char *argv[])
{
  struct sigaction action;
  struct pollfd pfd;
  int rc, blfd;
  int timeout, prev = -1;
  /* possible brightness levels for x1
   * - 3		off
   * - 67	medium
   * - 131	max
   */
  char bm[1];
  bm[0] = BRGHT_MED;

  memset(&action, 0, sizeof(struct sigaction));
  action.sa_handler = term;
  sigaction(SIGTERM, &action, NULL);

  // potentially needs
  // sudo modprobe -r ec_sys
  // sudo modprobe ec_sys write_support=1
  blfd = open("/sys/kernel/debug/ec/ec0/io", O_WRONLY);
  // needs the event bound to the keyboard
  // for Xorg ie find using
  //  cat /var/log/Xorg.0.log | grep "keyboard.*event"
  pfd.fd = open("/dev/input/event4", O_RDONLY);
  pfd.events = POLLIN;
  timeout = IDLE_MSEC;

  while (running) {
    rc = poll(&pfd, 1, timeout);
    if (rc) {
      /* got keyboard input, flush it all and
       * wait for the next event.
       */
      read(pfd.fd, dummybuf, sizeof(dummybuf));
      timeout = IDLE_MSEC;
      bm[0] = BRGHT_MED;
    } else {
      /* once we've gotten a timeout, turn off
       * kbd backlight and wait forever for
       * the next keypress
       */
      timeout = -1;
      bm[0] = BRGHT_OFF;
    }
    if (bm[0] == prev)
      continue;
    lseek(blfd, 13, SEEK_SET);
    write(blfd, bm, 1);
    prev = bm[0];
  }
  // clean up after sigterm
  bm[0] = BRGHT_OFF;
  lseek(blfd, 13, SEEK_SET);
  write(blfd, bm, 1);
}

This file can be compiled with:

 gcc -O2 -o kbdbacklight kbdbacklight.c

and must be executed as root. Furthermore, following kernel modules must be loaded for this to work:

 modprobe -r ec_sys
 modprobe ec_sys write_support=1

It would be possible to autostart this by creating a systemd service as follows:

  • Create a folder /usr/local/customscripts/kbdbacklight/
  • Save the compiled c program to /usr/local/customscripts/kbdbacklight/kbdbacklight
  • Create the following bash script in the same folder:
/usr/local/customscripts/kbdbacklight/kbdbacklight.sh
#!/bin/bash
# must be executed as root
modprobe -r ec_sys
modprobe ec_sys write_support=1
./kbdbacklight &
RETVAL=$?
PID=$!
[ $RETVAL -eq 0 ] && echo $PID > /usr/local/customscripts/kbdbacklight/pid
  • Create the following systemd service and place it in /etc/systemd/system/kbdbacklight.service
/etc/systemd/system/kbdbacklight.service
#!/bin/bash
[Unit]
Description=starts a daemon monitoring keyboard usage. will turn on keyboard backlight until no key is pressed for a TIMEOUT period
Requires=
After=

[Service]
Type=forking
User=root
WorkingDirectory=/usr/local/customscripts/kbdbacklight/
ExecStart=/usr/local/customscripts/kbdbacklight/kbdbacklight.sh &
PIDFile=/usr/local/customscripts/kbdbacklight/pid

[Install]
WantedBy=multi-user.target
  • activate the service with
 systemctl enable kbdbacklight
 systemctl start kbdbacklight
Note:

Specifiy the amount timeout for turning the backlight off again by adjusting the constant IDLE_MSEC in the c program. (and recompiling it again)

Audio

Sound works out of the box. Uses the snd_hda_intel kernel module. You may need to add default sound card options to the module.

In /etc/modprobe.d/alsa-base.conf include the following line:

options snd_hda_intel index=1

Processor

See Microcode how to update to processor's microcode.

BIOS UPDATE

To install a BIOS update from linux, download the bootable iso from here:

https://pcsupport.lenovo.com/fi/en/products/LAPTOPS-AND-NETBOOKS/THINKPAD-X-SERIES-LAPTOPS/THINKPAD-X1-CARBON-TYPE-20A7-20A8/downloads/DS039783

Since there is no CD drive, this method can be used (German):

https://thinkwiki.de/BIOS-Update_ohne_optisches_Laufwerk_unter_Linux#El_Torito_Image_auf_USB-Stick_.28nur_UEFI.29

Add ALSA-Preamplifier

It is a common problem on laptops running linux that the sound, even on maximum, is not loud enough. This can be fixed by adding an ALSA preamplifier.

Install alsa-utils.

Change the config in /etc/asound.conf to the following ( you might have to adjust the cardnumber):

# Set your DEFAULT device to the softvol plug-in
# NOT to a hardware card device
#
# The "!" means completely override the previous default
# Not just changing/adding to it.
pcm.!default {
  type plug
  slave.pcm "softvol"
}

# Configure softvol
pcm.softvol {
  type softvol

  # Send softvol's output to dmix
  slave {
    pcm "dmix"
    # If you wanted to you could send the output to a card directly
    # But in most cases it's better to send it to dmix and let
    # dmix handle where to send it. You can add a whole extra section
    # to configure dmix and where it sends output, but I'm
    # not covering that here.

    ## Use Card 0 Device 0 instead of dmix
    # pcm "hw:0,0"
    ## Use Card 2 Device 0 instead of dmix
    # pcm "hw:2,0"
  }

  # Add a control slider in your mixer interfaces
  # i.e. KMix and alsamixer
  control {
    name "Pre-Amp"
    card 0 #<CardNumberYouWantControlToShowOn> i.e. card 0 or card 2
  }

  # Minimum dB when slider is at 0%
  min_dB -5.0

  # Maximum DB when slider is at 100%
  max_dB 40.0

  # How many levels the slider should go through
  # i.e. how granular do you want your control to be
  resolution 12
}

Taken from here. WARNING: It is possible to permanently damage your loudspeakers if you turn it up too much!

Network

Wired

There is a small port on the right side for Ethernet. An adaptor is required. In case of loss of the adaptor, the part number is for ordering is 04X6435.

Wireless

Works out of the box. The module iwlwifi should be automatically loaded by udev.

$ lspci
Network controller: Intel Corporation Wireless 7260 (rev 83)

Display

Touchscreen

Works out of the box as single touch. The hardware is multitouch, but current stable drivers only support left-click mouse emulation. Seems to work with Touchegg.

GPU

The video card installed is an integrated Intel Haswell GPU. See intel for more info.

HiDPI

Since the display has such a high pixel density, you might encounter problems. See here: HiDPI

Xbindkeys

For alternative window managers (Fluxbox, etc..), try installing xbindkeys and adding the following to ~/.xbindkeysrc

"xbacklight -dec 5"
  XF86MonBrightnessDown
"xbacklight -inc 5"
  XF86MonBrightnessUp

KMS

Get KMS working by adding i915 to the modules line

/etc/mkinitcpio.conf
MODULES="i915"

Then regenerate your initramfs:

# mkinitcpio -p linux

Webcam

Works out of the box.

Fingerprint Reader

The fingerprint reader is a Validity Sensors model (138a:0017) also used on the Thinkpad X240 and T440. ThinkFinger does NOT support this reader.

This fingerprint reader works with the current release of fprint.

WWAN (Mobile broadband)

The SIM-card must be inserted in the back of the laptop.

This is usually a Sierra Wireless EM7345. It uses the cdc_mbim kernel module from kernel 3.14 forward. Since Gnome 3.14.1 it works with NetworkManager after installing modemmanager (after a reboot to catch the udev event).

GPS

This is provided by the Sierra Wireless EM7345. mbim_gpsd is required as well as a udev rule.

Untested

Bluetooth

Works out of the box after enabling bluetooth.service.

See also