Skip to content

Instantly share code, notes, and snippets.

@fbrozovic
Last active April 30, 2020 23:53
Show Gist options
  • Save fbrozovic/9102118 to your computer and use it in GitHub Desktop.
Save fbrozovic/9102118 to your computer and use it in GitHub Desktop.

Debian on ThinkPad W540

This is a short write-up of my experiences with installing Debian on a ThinkPad W540.

All commands should be run as root, unless indicated otherwise.

Table of Contents

Debian Install Notes

NVIDIA Graphics Driver

LCD Brightness Keys

ClickPad Configuration

Fingerprint Sensor (VFS5011)

## Debian Install Notes

With debian-testing-amd64-netinst.iso (from 20140217), when installing from an USB stick created with Rufus, the installation failed with an error saying that no package sources were configured. Burning the same ISO to a CD and installing from it solved the problem.

## NVIDIA Graphics Driver

After installing the system and booting into the system for the first time, we are going to install the graphics drivers for the Quadro K1100M/K2100M:

  • Add the non-free and contrib repositories to /etc/apt/sources.list
  • Add multiarch support for i386: dpkg --add-architecture i386
  • Run apt-get update and install the necessary packages: apt-get install nvidia-kernel-dkms bumblebee-nvidia primus primus-libs:i386
  • Add users to the bumblebee group with adduser $USER bumblebee
  • Reboot and check whether GPU switching works:
  # cat /proc/acpi/bbswitch
  0000:01:00.0 OFF
  # echo ON > /proc/acpi/bbswitch && cat /proc/acpi/bbswitch
  0000:01:00.0 ON
  # echo OFF > /proc/acpi/bbswitch
  • If GPU switching works, edit /etc/bumblebee/bumblebee.conf and change the following two lines:
  Driver = nvidia
  KernelDriver = nvidia-current
  • Reboot and check whether optirun works with optirun glxgears. If there are no errors on the console, bumblebee is now correctly configured!
## LCD Brightness Keys

Most likely, the brightness keys will not work out of the box. To make them work, edit /etc/default/grub:

  GRUB_CMDLINE_LINUX_DEFAULT="quiet acpi_osi=\"!Windows 2012\""

Run update-grub and reboot.

## ClickPad Configuration

Since the W540 doesn't have physical TrackPoint buttons anymore, an adjustment to the synaptics driver configuration is needed to get (approximately) the same feel as in Windows. I haven't gotten scrolling using the middle button working yet, but I will update this document when I do.

  • Create the directory /etc/X11/xorg.conf.d if it doesn't exist yet
  • Create a file named 50-synaptics-clickpad.conf in the above directory with the following contents:
Section "InputClass"
        Identifier "touchpad catchall"
        Driver "synaptics"
        MatchIsTouchpad "on"
# This option is recommend on all Linux systems using evdev, but cannot be
# enabled by default. See the following link for details:
# http://who-t.blogspot.com/2010/11/how-to-ignore-configuration-errors.html
        MatchDevicePath "/dev/input/event*"
        Option  "HorizScrollDelta"      "0"
        Option "MinSpeed" "1"
        Option "MaxSpeed" "1"
        Option "AccelerationProfile" "2"
        Option "AdaptiveDeceleration" "16"
        Option "ConstantDeceleration" "16"
        Option "VelocityScale" "32"
# enable tap-to-click as default (bnc#722457)
        Option "TapButton1" "1"
        Option "TapButton3" "2"
        Option "TapButton2" "3"
EndSection


Section "InputClass"
        Identifier "touchpad ignore duplicates"
        MatchIsTouchpad "on"
        MatchOS "Linux"
        MatchDevicePath "/dev/input/mouse*"
        Option "Ignore" "on"
EndSection


# This option enables the bottom right corner to be a right button on
# non-synaptics clickpads.
# This option is only interpreted by clickpads.
Section "InputClass"
        Identifier "Default clickpad buttons"
        MatchDriver "synaptics"
#        Option "SoftButtonAreas" "50% 0 82% 0 0 0 0 0"
        Option "AreaTopEdge" "2700"
        Option "SoftButtonAreas" "65% 0 0 3500 35% 65% 0 3500"
#       To disable the bottom edge area so the buttons only work as buttons,
#       not for movement, set the AreaBottomEdge
EndSection

After a reboot, you should now be able to use the upper part of the clickpad as TrackPoint buttons. If desired, you can change the AreaTopEdge parameter in the configuration file. Increasing the value moves the top edge of the active area further away from the top edge of the clickpad, meaning that there will be a bigger area in which you will not be able to move the mouse pointer with the touchpad; decreasing it will do the opposite.

## Fingerprint Sensor (VFS5011)
  • Install the necessary packages:
apt-get install git libmagickcore-dev libusb-1.0-0-dev libnss3-dev libglib2.0-dev libtool fprintd automake libxv-dev libpam-fprintd build-essential fprint-demo
  • Grab the driver sources: git clone git://github.com/abbradar/fprint_vfs5011.git
  • In the fprint_vfs5011 directory, run ./autogen.sh && ./configure --prefix=/usr
  • There is a bug in the makefile, so you have to edit libfprint/Makefile and find the fprint-list-udev-rules target. At the end of the line that starts with $(AM_V_CCLD), add $(GLIB_LIBS):
$(AM_V_CCLD)$(fprint_list_udev_rules_LINK) $(fprint_list_udev_rules_OBJECTS) $(fprint_list_udev_rules_LDADD) $(LIBS) $(GLIB_LIBS)
  • Now we can compile and install the library: make && make install
  • In order for users to be able to access the fingerprint reader, we are going the have to add the following section to /lib/udev/rules.d/60-libfprint0.rules:
# Validity VFS5011
SUBSYSTEM=="usb", ATTRS{idVendor}=="138a", ATTRS{idProduct}=="0017", ATTRS{dev}=="*", ATTR{power/control}="auto", MODE="0664", GROUP="plugdev"
  • Reboot your machine and run fprint_demo. The fingerprint reader should be recognized and you should be able to enroll your fingers.
@shuxuekkl
Copy link

Does all this work in ubuntu 14.04?

@robolange
Copy link

I just installed Debian testing (currently, Jessie) right after the switch to kernel 3.16, and have a couple of amendments:

  1. Brightness keys work out of the box.
  2. For GPU switching to work, you must make the following patch to /etc/default/grub:
-GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
+GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=\"!Windows 2013\""

and run update-grub and reboot.

@robolange
Copy link

I am experimenting with Debian testing. The AreaTopEdge option of the Xorg configuration does not seem to be required anymore. Also, it seems that the SoftButtonAreas option does not set the correct positions of the left and right buttons on the ThinkPad w540. After poking around in the synaptics man page, it turns out that the w540 uses the "secondary" soft buttons. I rewrote the clickpad buttons section of the above 50-synaptics-clickpad.conf file so that the settings work correctly now:

# This option is only interpreted by clickpads.
Section "InputClass"
        Identifier "default clickpad buttons"
        MatchDriver "synaptics"
        Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
        Option "HasSecondarySoftButtons" "true"
        Option "SecondarySoftButtonAreas" "65% 0 0 25% 35% 65% 0 25%"
EndSection

For reference, the user can query the current settings of the ClickPad using the following command:

xinput list-props "SynPS/2 Synaptics TouchPad"

The user can also dynamically change the settings of the ClickPad using a command similar to the following:

xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Secondary Soft Button Areas" 3681 0 0 2726 2454 3681 0 2726

Like the Xorg config file option, the order of the parameters in this command is right button left edge, right button right edge, right button top edge, right button bottom edge, middle button left edge, middle button right edge, middle button top edge, middle button bottom edge. However, you must use absolute coordinates rather than percentages.

@s-a-m
Copy link

s-a-m commented Oct 19, 2014

You have additional helpful configuration suggestions for the W540 touchpad in:
http://www.thinkwiki.org/wiki/Buttonless_Touchpad

@andrewgdunn
Copy link

I'm thinking of buying one of these. By default are you using the Intel adapter? I'd likely be using the intel adapter 90% of the time and would like the battery life savings from it. On the Dell M4800 they disable the use of the intel adapter and force you to use the K2100M all the time (on the HiDPI model).

@jlippi
Copy link

jlippi commented Jan 8, 2015

Hi,
I had a couple more problems with ubuntu that I just figured out:

I did what @damianorenfer above did with bumblebee, and then I did two other things:
edit /etc/defaults/grub:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

GRUB_CMDLINE_LINUX_DEFAULT='quiet splash acpi_osi="!Windows 2013"'

GRUB_CMDLINE_LINUX="nomodeset"

GRUB_CMDLINE_LINUX=""

I then ran sudo update-grub

the first of these changes allowed the bumblebee switching to work.
the second allowed bumblebee to actually load and use the nvidia driver

also had to do sudo apt-get install libgl1-mesa-glx:i386 before i installed nvidia-bumblebee.

Cheers,
Justin

@robolange
Copy link

So after a year of nearly flawless use on Debian testing (was jessie, now stretch) a recent update has caused a regression and now most of the top-row Thinkpad keys do not work and suspend-on-screen-close also does not work. Anyone else see this?

I can change the volume and brightness by the GUI or via command line, but the buttons don't work anymore. The Wifi button still works, and the Nvidia card can still be activated/deactivated via optirun. The Internet icon button (second from the right above the number pad) still works. But none of the other top-row buttons even show up as keypresses in xev anymore.

I had acpi_osi=\"!Windows 2013\" in GRUB_CMDLINE_LINUX_DEFAULT. I also tried acpi_osi=\"Linux\" and while it didn't help, it didn't hurt either, as Bumblebee still worked.

Anyone have any idea how to begin debugging this? Or even just to figure out what package to file a bug against?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment