Configuring ROSA Desktop Fresh R5 for ThinkPad X61 Tablet

Non-LTS (non-Marathon) related topics
Ответить
Аватара пользователя
dsch
Сообщения: 17
Зарегистрирован: 28 сен 2014, 21:09
Operating system: ROSA Desktop Fresh R5
Откуда: Greece, Bulgaria
Контактная информация:

Configuring ROSA Desktop Fresh R5 for ThinkPad X61 Tablet

Сообщение dsch » 28 июн 2015, 02:47

First of all, I would like to ask the administrators and moderators of the forum to create a new section for ROSA Desktop Fresh R5, since it doesn't seem to exist one.

This post is more of wiki or a tutorial, than a forum post and I apologize, in advance, if it shouldn't be posted here, but elsewhere, in which case, I would like the administrators and moderators of the forum to point me to the right direction. I am writing this, to help other ROSA users, to express my love for ROSA Linux and to contribute in a way to its further development and increase of its popularity.

If it happened to own a Lenovo ThinkPad X61 Tablet, and installed ROSA Desktop Fresh R5 on it, you have probably came across some issues. Most of the issues seem to be present for most other majors distributions, but I will be specific for ROSA in this text.

The installation process of ROSA Desktop Fresh R5, runs smoothly on Lenovo ThinkPad X61 Tablet and installs without any issues, but not everything works out of the box!
What does not work:
  • 1. Middle button of TrackPad/TrackPoint
  1. 2. ThinkVantage button
  • 3. Digital Pen, eraser and right click button
  • 4. Screen automatic rotation
  • 5. Screen bezel buttons
  • 6. Fingerprint
I managed to get most of them to work, but the process was not easy and most of all it was time consuming. Thus, I decided to write this text, to save some time for others.

So, let's start!

I use nano editor for text editing in terminal, which is not installed by default. Thus, either install nano by executing the following command, or use your favourite editor.

Код: Выделить всё

sudo urpmi nano
1. Middle button of TrackPad/TrackPoint
  • In order to get the middle button of TrackPad/TrackPoint to work as intended, i.e. for scrolling, all you have to do is instruct Xorg to do it.

    Open Konsole and type the following:

    Код: Выделить всё

    sudo nano /etc/X11/xorg.conf
    Most probably the file will not exist or it will be empty, if for some reason it exists, you will have to edit it in order to include all the following settings. Otherwise, create it and simply add them to it.

    The settings are the following:

    Код: Выделить всё

    Section "InputClass"
    Identifier "Trackpoint Wheel Emulation"
    MatchProduct "TPPS/2 IBM TrackPoint|DualPoint Stick|Synaptics Inc. Composite To$
    MatchDevicePath "/dev/input/event*"
    Option "EmulateWheel" "true"
    Option "EmulateWheelButton" "2"
    Option "Emulate3Buttons" "false"
    Option "XAxisMapping" "6 7"
    Option "YAxisMapping" "4 5"
    EndSection
    
    For the changes to take effect, X has to restart. Either reboot your system or execute the following commands. Keep in mind, however, that all open applications will close, without prior notification and any unsaved data will be lost, so save any open data and then execute the commands.

    Код: Выделить всё

    sudo init 3
    This will drop X and a command line session will start. Login, and type:

    Код: Выделить всё

    sudo init 5
We are back here now and issue 1 is solved! Let's continue...

2. ThinkVantage button
  • The ThinkVantage button is recognized by the system, but nothing is assigned to it.
    We are going to use a program to assign an application to it.
    We are going to use this program to assign applications to all screen bezel buttons, so please do not skip this step!

    Open a Konsole and type:

    Код: Выделить всё

    sudo urpmi xbindkeys
    Then, type:

    Код: Выделить всё

    xbindkeys --defaults > .xbindkeysrc
    This will create the default configuration file for xbindkeys under your home directory.
    Now, open the configuration file for editing:

    Код: Выделить всё

    nano ~/.xbindkeysc
    and add the following lines to it:

    Код: Выделить всё

    # ThinkVantage Button | Configure Desktop
    "systemsettings"
      m:0x0 + c:156
    I have assigned the ThinkVantage button to system settings application, which in my view it makes sense. If you like you can change that, by changing the configuration file accordingly.

    Now, type in Konsole:

    Код: Выделить всё

    xbindkeys
    to run the program and press the ThinkVantage button to see if it works. If it does, everything is cool, if not review the process above and/or write me a reply.

    Now, we need to add xbindkeys to our startup application so that the button assignment will continue to work after your reboot your laptop.
    We can do that in many ways, let's use that easiest one:
    Press the ThinkVantage button, go to Startup and Shutdown, press the Add Program... at right of the window, type xbindkeys in the textbox, check the Run in terminal checkbox and click OK.
Now, the ThinkVantage button works, too!

3. Digital Pen, eraser and right click button
  • The Digital Pen issue, is probably the easiest to solve of them all!
    Open a Konsole and type:

    Код: Выделить всё

    sudo urpmi kcm_wacomtablet
    Log out and login again, press the ThinkVantage button, go to Input Devices and now you will find there a Graphic Tablet section, under which and at the Stylus tab, you can configure the button to behave as right click.
4. Screen automatic rotation
  • To get the screen to automatically rotate together with the orientation of the Digital Pen, follow the steps below:
    Open a Konsole and create a hidden directory under your home directory:

    Код: Выделить всё

    mkdir ~/.autorotate-thinkpad
    While you are still in the Konsole, create a file named rotationmode and fill it with a 0:

    Код: Выделить всё

    echo 0 > ~/.autorotate-thinkpad/rotationmode
    Now, still in the Konsole, find the name of your Digital Pen device, using xinput: You should have three entries with the following or similar names, write them down:
    Wacom Serial Penabled Touchscreen stylus
    Wacom Serial Penabled Touchscreen eraser
    TPPS/2 IBM TrackPoint

    Now, in Konsole, create another file and open it for editing:

    Код: Выделить всё

    nano ~/.autorotate-thinkpad/rotationbutton.sh
    Enter the following code inside:

    Код: Выделить всё

    #!/bin/bash
    
    mode=`cat /home/$USER/.autorotate-thinkpad/rotationmode`
    if [[ 0 = $mode ]];
    then
    echo 1 > /home/$USER/.autorotate-thinkpad/rotationmode
    xrandr -o right
    xsetwacom set "Wacom Serial Penabled Touchscreen stylus" rotate cw
    xsetwacom set "Wacom Serial Penabled Touchscreen eraser" rotate cw
    xinput set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 0
    xmodmap - <<END
    keycode 114 = Up NoSymbol Up NoSymbol Up
    keycode 111 = Left NoSymbol Left NoSymbol Left
    keycode 116 = Right NoSymbol Right NoSymbol Right
    keycode 113 = Down NoSymbol Down NoSymbol Down
    END
    fi
    if [[ 1 = $mode ]];
    then
    echo 2 > /home/$USER/.autorotate-thinkpad/rotationmode
    xrandr -o inverted
    xsetwacom set "Wacom Serial Penabled Touchscreen stylus" rotate half
    xsetwacom set "Wacom Serial Penabled Touchscreen eraser" rotate half
    xinput set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 0
    xmodmap - <<END
    keycode 111 = Down NoSymbol Down NoSymbol Down
    keycode 113 = Right NoSymbol Right NoSymbol Right
    keycode 114 = Left NoSymbol Left NoSymbol Left
    keycode 116 = Up NoSymbol Up NoSymbol Up
    END
    fi
    if [[ 2 = $mode ]];
    then
    echo 3 > /home/$USER/.autorotate-thinkpad/rotationmode
    xrandr -o left
    xsetwacom set "Wacom Serial Penabled Touchscreen stylus" rotate ccw
    xsetwacom set "Wacom Serial Penabled Touchscreen eraser" rotate ccw
    xinput set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 0
    xmodmap - <<END
    keycode 114 = Down NoSymbol Down NoSymbol Down
    keycode 111 = Right NoSymbol Right NoSymbol Right
    keycode 116 = Left NoSymbol Left NoSymbol Left
    keycode 113 = Up NoSymbol Up NoSymbol Up
    END
    fi
    if [[ 3 = $mode ]];
    then
    echo 0 > /home/$USER/.autorotate-thinkpad/rotationmode
    xrandr -o normal
    xsetwacom set "Wacom Serial Penabled Touchscreen stylus" rotate none
    xsetwacom set "Wacom Serial Penabled Touchscreen eraser" rotate none
    xinput set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 1
    xmodmap - <<END
    keycode 111 = Up NoSymbol Up NoSymbol Up
    keycode 113 = Left NoSymbol Left NoSymbol Left
    keycode 114 = Right NoSymbol Right NoSymbol Right
    keycode 116 = Down NoSymbol Down NoSymbol Down
    END
    fi
    Check the names of your xinput entries you wrote down before and change the above code accordingly, if needed.

    Create one more file:

    Код: Выделить всё

    nano ~/.autorotate-thinkpad/autorotate-thinkpad.sh
    Enter the following code inside:

    Код: Выделить всё

    #!/bin/bash
    
    old="0"
    while true; do
    	if [[ -e /sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode ]]; then
    		new=`cat /sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode`
    		if [[ $new != $old ]]; then
    			if [[ $new == "0" ]]; then
    				echo "Rotate to landscape."
    				killall cellwriter
    				xrandr -o normal
    				xsetwacom set "Wacom Serial Penabled Touchscreen stylus" rotate none
    				xsetwacom set "Wacom Serial Penabled Touchscreen eraser" rotate none
    				xinput set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 1
    xmodmap - <<END
    keycode 111 = Up NoSymbol Up NoSymbol Up
    keycode 113 = Left NoSymbol Left NoSymbol Left
    keycode 114 = Right NoSymbol Right NoSymbol Right
    keycode 116 = Down NoSymbol Down NoSymbol Down
    END
    			elif [[ $new == "1" ]]; then
    				echo "Rotate to portrait."
    				xrandr -o right
    				xsetwacom set "Wacom Serial Penabled Touchscreen stylus" rotate cw
    				xsetwacom set "Wacom Serial Penabled Touchscreen eraser" rotate cw
    				xinput set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 0
    xmodmap - <<END
    keycode 114 = Up NoSymbol Up NoSymbol Up
    keycode 111 = Left NoSymbol Left NoSymbol Left
    keycode 116 = Right NoSymbol Right NoSymbol Right
    keycode 113 = Down NoSymbol Down NoSymbol Down
    END
    			fi
    		fi
    		old=$new
    		sleep 1s
    	fi
    done
    Again, change the above code with respect with your xinput, if needed.

    Finally, we need make these files executable:

    Код: Выделить всё

    sudo chmod +x ~/.autorotate-thinkpad/*
    and configure the autorotate-thinkpad.sh to start at boot.
    Again, we are going to choose the easiest way:

    Press the ThinkVantage button, go to Startup and Shutdown, press the Add Script... at right of the window, type ~/.autorotate-thinkpad/autorotate-thinkpad.sh in the textbox, check the Create as symlink checkbox and click OK.

    You can make everything work by either log out and log back in, or by just running the autorotate-thinkpad.sh script:

    Код: Выделить всё

    bash ~/.autorotate-thinkpad/autorotate-thinkpad.sh
Automatic rotation is achieved and we have also made our homework for the following section.

5. Screen bezel buttons
  • All screen bezel buttons are recognized by the atkbd driver, which unfortunately is not loaded into the kernel by default.
    Subsequently, we have to configure GRUB to load the driver into the kernel on boot. To do so, open a Konsole and type the following:

    Код: Выделить всё

    sudo nano /etc/default/grub
    Add the atkbd.softraw=0 option in the GRUB_CMDLINE_LINUX_DEFAULT line.
    This will change the line from:

    Код: Выделить всё

    GRUB_CMDLINE_LINUX_DEFAULT='splash=silent logo.nologo'
    
    to:

    Код: Выделить всё

    GRUB_CMDLINE_LINUX_DEFAULT='splash=silent atkbd.softraw=0 logo.nologo'
    
    Now, we have to rebuild GRUB, for the changes in the configuration file to be applied:

    Код: Выделить всё

    sudo update-grub2
    Finally, we must reboot our system. Sorry, this is a kernel operation and reboot is required!

    We are back, and now the system recognizes the screen bezel buttons but again nothing is assigned to them.
    We should then configure them under xbindkeys.... Yes, but not yet!

    Modern Linux system like ROSA Desktop Fresh R5, use udev for button mapping and this will conflict with xbindkeys, resulting in abnormal behaviour.
    Thus, to correctly get the buttons to work, we have to make changes in the hardware database.
    The configuration file for buttons of any system is located under:

    Код: Выделить всё

    /lib/udev/hwdb.d/60-keyboard.hwdb
    If you open skim the file, you will find that there are default configurations for the ThinkPad X6* models, but for same reason they are not loaded.
    The reason is, that, at least in my case, the product name of my laptop was not ThinkPad X6*, but rather it was the actual model of the laptop, i.e. 776295G.
    To find yours, open a Konsole and type:

    Код: Выделить всё

    cat /sys/class/dmi/id/sys_vendor
    This should print LENOVO and:

    Код: Выделить всё

    cat /sys/class/dmi/id/product_name
    This should print your model number, write it down somewhere, we are need it!

    We are going to create a new hardware database configuration file:

    Код: Выделить всё

    sudo nano /lib/udev/hwdb.d/70-keyboard.hwdb
    
    And fill it with the following:

    Код: Выделить всё

    # ThinkPad X61 Tablet
    keyboard:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn776295G:pvr*
     KEYBOARD_KEY_6c=prog3                                  # rotate
     KEYBOARD_KEY_68=prog4                                  # toolbox
     KEYBOARD_KEY_6b=esc                                    # escape
     KEYBOARD_KEY_6d=right                                  # right on d-pad
     KEYBOARD_KEY_6e=left                                   # left on d-pad
     KEYBOARD_KEY_71=up                                     # up on d-pad
     KEYBOARD_KEY_6f=down                                   # down on d-pad
     KEYBOARD_KEY_69=enter                                  # enter on d-pad
     KEYBOARD_KEY_67=prog2                                  # ctrl-alt-del
    
    Pay attention at the second line! Change the 776295G, with the number of your model, that you've written down before.
    Now, that we have created our configuration file, we have to compile the hwdb for changes and additions to take effect in the hwdb.bin file:

    Код: Выделить всё

    /lib/udev/hwdb.bin
    We are going to do it, with the following commands:

    Код: Выделить всё

    sudo udevadm hwdb --update
    sudo udevadm trigger /dev/input/event*
    
    Like with GRUB, this is a kernel related operation, thus we need to reboot our system at this point.

    Now, after the reboot we are ready to deal with our xbindkeys configuration.
    But before that, there one last thing we need to do. We need to install a virtual keyboard to use, when in tablet mode.
    There are a lot of options here, select one that you prefer. In my opinion, none of them is good!
    There is a lack of beautiful and functional virtual keyboards in KDE and in Linux in general.
    Debian 8 and from there, Ubuntu and Mint have a nicer solution in their newest versions, but still not good enough virtual keyboards.
    In a world of smartphones, where virtual keyboards are so advanced with word prediction, auto-fill, handwriting recognition and much more features, Linux seems to be ages behind. Even Microsoft Windows has much better virtual keyboards.
    I ended up selecting, cellwriter. It looks outdated and it is, but still with lots of efforts, it will learn and recognize your handwriting and its on screen keyboard is acceptable. If you choose to go with my solution, write the following command in Konsole to install it:

    Код: Выделить всё

    sudo urpmi cellwriter
    Now, that we have a virtual keyboard installed, you shall proceed with our xbindkeys configuration.
    To edit the configuration file, type in Konsole:

    Код: Выделить всё

    nano ~/.xbindkeysrc
    and append the following code inside:

    Код: Выделить всё

    # Ctrl-Alt-Del | KDE Leave Menu
    "qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 1 -1 -1"
      m:0x0 + c:157
    
    # Rotation Button | Custom Rotation Script
    "bash /home/$USER/.autorotate-thinkpad/rotationbutton.sh"
      m:0x0 + c:210
    
    # Toolbox Button |
    "cellwriter"
      m:0x0 + c:211
    
    You can now, either log out and log back in or simply kill and restart xbindkeys from Konsole:

    Код: Выделить всё

    killall xbindkeys
    xbindkeys
We have now configured all screen bezel buttons, with similar functionality to their original under Microsoft Windows and Lenovo drivers.
The only thing that is left is to configure the fingerprint reader to store our password and login and root permissions authorization.

6. Fingerprint

Here is the point, where I am going to disappoint you though!
The fingerprint reader, as a device, is recognized by the kernel and if you install fprintd you can actually store your fingerprints and use them to give root permissions, but unfortunately only under Konsole, when in GUI, you are not given the option.
You can also login using your fingerprint, but the process is very ugly! You have to press enter, without entering a password at login screen (without any indication that the system is waiting for your fingerprint), an un-themed window will open, with a message asking you to swipe your finger and after you do that (without an indication on whether you have done it successfully or not), you have to click the OK button, with the mouse pointer, because the focus is not there.

This is an illustration of the above:
IMG_20150625_114843.jpg
This is what I managed to do about the fingerprint reader and I didn't like it, so I removed it and I don't use the fingerprint reader apart from the BIOS login at boot.
I don't give detailed instructions, because I didn't like it, but if somebody wants assistance with that, please don't hesitate to post a reply below.

That covers pretty much all my work, installing ROSA Desktop Fresh R5 on a Lenovo ThinkPad X61 Tablet.
I hope that this post will be helpful to somebody!
Dimitrios Charalampidis
Snail Trading Ltd.

Ответить