From ae1b9350cff93d1e25a48bf301dc5494cd781d18 Mon Sep 17 00:00:00 2001 From: Aqeel Akber Date: Sun, 4 Jan 2015 00:27:30 +1000 Subject: [PATCH] Fixed tablet mode --- PKGBUILD | 12 ++++-------- README.md | 30 ++++++++++++++++++++++-------- systemd/yoga-tablet.service | 13 +++++++++++++ tablet/mouse-toggle.sh | 26 ++++++++++++++++++++++++++ tablet/tablet-mode | 2 -- tablet/tablet-mode.sh | 32 ++++++++++++++------------------ tablet/xbindkeysrc | 6 ++++++ 7 files changed, 85 insertions(+), 36 deletions(-) create mode 100644 systemd/yoga-tablet.service create mode 100755 tablet/mouse-toggle.sh delete mode 100644 tablet/tablet-mode create mode 100644 tablet/xbindkeysrc diff --git a/PKGBUILD b/PKGBUILD index a80e2df..b2ca7cb 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -9,7 +9,7 @@ url="https://github.com/admiralakber/thinkpad-yoga-scripts" source=('thinkpad-yoga-scripts::git+https://github.com/admiralakber/thinkpad-yoga-scripts') license=('GPL3') arch=('any') -depends=('xorg-xrandr' 'acpid' 'xorg-xinput') +depends=('xorg-xrandr' 'xorg-xinput' 'xbindkeys' 'kbd' 'systemd' 'gawk') optdepends=( 'onboard: onscreen keyboard' 'xf86-input-wacom: for digitizer support' @@ -24,18 +24,14 @@ pkgver() { package() { cd $srcdir/$_gitname - # Disable touchpad when moving to tablet mode - mkdir -p "$pkgdir/etc/acpi/events" - install -m 644 tablet/tablet-mode "$pkgdir/etc/acpi/events" - mkdir -p "$pkgdir/etc/acpi/actions" - install -m 755 tablet/tablet-mode.sh "$pkgdir/etc/acpi/actions" - - # Other scripts into /opt + # Install scripts into /opt mkdir -p "$pkgdir/opt/$_gitname" ## Rotate scripts cp -r rotate "$pkgdir/opt/$_gitname" ## Wacom scripts cp -r wacom "$pkgdir/opt/$_gitname" + ## Tablet mode + cp -r tablet $pkgdir/opt/$_gitname" # ThinkPad Yoga Systemd Services mkdir -p "$pkgdir/usr/lib/systemd/system/" diff --git a/README.md b/README.md index a523bf6..a8130cb 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,44 @@ thinkpad-yoga-scripts ===================== -A collection of scripts and systemd units to restore functionality of the Lenovo ThinkPad Yoga S1. +A collection of scripts and systemd units to restore functionality of +the Lenovo ThinkPad Yoga S1. + +These are different from other scripts in that the screen rotation is +automated with use of the inbuilt accelerometer. Also, acpid is not +used in order to toggle between tablet mode but rather binding to the +inbuilt switches. Tested on Arch Linux with MATE Desktop Environment. # Scripts should fix: -- Screen rotation with accelerometer, including touchscreen, Wacom, and Touchpad/TrackPoint geometries +- Screen rotation with accelerometer, including touchscreen, Wacom, + and Touchpad/TrackPoint geometries + - Disabling of Touchscreen with proximity of Wacom digitizer + - Disabling of Clickpad and TrackPoint when moving to tablet mode # TODO: -- Test on different desktop environments +- Test on different desktop environments (You can help!) # Dependencies - xrandr -- acpid - xinput +- xbindkeys +- kbd +- systemd - xsetwacom (optional for wacom rotation) - onboard (optional for onscreen keyboard) # Manual installation + sudo -s git clone https://github.com/admiralakber/thinkpad-yoga-scripts /opt/thinkpad-yoga-scripts - cp /opt/thinkpad-yoga-scripts/systemd/* /etc/systemd/system/* - cp /opt/thinkpad-yoga-scripts/tablet/tablet-mode /etc/acpi/events - cp /opt/thinkpad-yoga-scripts/tablet/tablet-mode.sh /etc/acpi/actions - exit \ No newline at end of file + cp systemd/* /usr/lib/systemd/system + + systemctl start wacom-proximity@username.service + systemctl start yoga-rotate@username.service + systemctl start yoga-tablet.service + \ No newline at end of file diff --git a/systemd/yoga-tablet.service b/systemd/yoga-tablet.service new file mode 100644 index 0000000..1372536 --- /dev/null +++ b/systemd/yoga-tablet.service @@ -0,0 +1,13 @@ +[Unit] +Description=[ThinkPad Yoga] Tablet mode +Requires=display-manager.service +After=display-manager.service + +[Service] +ExecStart=/usr/bin/bash /opt/thinkpad-yoga-scripts/tablet/tablet-mode.sh +KillMode=process +Environment="DISPLAY=:0" +Type=forking + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/tablet/mouse-toggle.sh b/tablet/mouse-toggle.sh new file mode 100755 index 0000000..3f7c603 --- /dev/null +++ b/tablet/mouse-toggle.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Simple script to toggle on/off the ThinkPad Yoga's Trackpoint and Clickpad +# and kill/launch. To be binded with switches when switching between tablet/laptop +# modes. +# +# Must be run as user running X11. +# +# https://github.com/admiralakber/thinkpad-yoga-scripts +# Author: AdmiralAkber + +#export XAUTHORITY=`ls -1 /home/*/.Xauthority | head -n 1` +#export DISPLAY=":`ls -1 /tmp/.X11-unix/ | sed -e s/^X//g | head -n 1`" + +case "$1" in + off) + xinput --set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0 + xinput --set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 0 + sudo -b -u \#1000 onboard + ;; + on) + xinput --set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1 + xinput --set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 1 + killall onboard + ;; +esac + diff --git a/tablet/tablet-mode b/tablet/tablet-mode deleted file mode 100644 index 7babca0..0000000 --- a/tablet/tablet-mode +++ /dev/null @@ -1,2 +0,0 @@ -event=ibm/hotkey LEN0068:00 00000080 000060c0 -action=/etc/acpi/actions/tablet-mode.sh diff --git a/tablet/tablet-mode.sh b/tablet/tablet-mode.sh index 58b078b..a4c12ea 100755 --- a/tablet/tablet-mode.sh +++ b/tablet/tablet-mode.sh @@ -1,23 +1,19 @@ #!/bin/bash -# When converted to tablet, switch off touchpad, trackpoint, and launch onboard -# Since opening and closing tabletmode is signaled by the same ACPI event, the script toggles parameters. -# +# # https://github.com/admiralakber/thinkpad-yoga-scripts # -# Acknowledgements: -# Modified from source: djahma - https://forum.manjaro.org/index.php?topic=9671.0 -# and oggy-/thinkpad-yoga-rotate +# Set tablet/laptop scancodes on ThinkPad Yoga S1 to NoSymbol +# keycodes then run xbindkeys as the appropriate user with +# a custom configuration file. +# +# USAGE: tablet-mode.sh username -export XAUTHORITY=`ls -1 /home/*/.Xauthority | head -n 1` -export DISPLAY=":`ls -1 /tmp/.X11-unix/ | sed -e s/^X//g | head -n 1`" +config='/opt/thinkpad-yoga-scripts/tablet/xbindkeysrc' +user="$(who -u | grep -F \(${DISPLAY}\) | head -n 1 | awk '{print $1}')" -touchpad=$(xinput list-props "SynPS/2 Synaptics TouchPad" | grep "Device Enabled" | awk -F ":" '{print $2}') -if [ $touchpad -eq 1 ]; then - xinput --set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 0 - xinput --set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 0 - sudo -b -u \#1000 onboard -else - xinput --set-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 1 - xinput --set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" 1 - killall onboard -fi +# Set scancode to keycodes +setkeycodes e058 85 # Tablet mode +setkeycodes e059 89 # Laptop mode + +# Start xbindkeys with configuration file +su $user -c "xbindkeys -f $config" diff --git a/tablet/xbindkeysrc b/tablet/xbindkeysrc new file mode 100644 index 0000000..73584af --- /dev/null +++ b/tablet/xbindkeysrc @@ -0,0 +1,6 @@ +"/bin/bash /opt/thinkpad-yoga-scripts/tablet/mouse-toggle.sh off" + m:0x0 + c:93 +"/bin/bash /opt/thinkpad-yoga-scripts/tablet/mouse-toggle.sh on" + m:0x0 + c:97 + +