use acpi listen to trigger tablet mode

This commit is contained in:
wassname
2019-03-14 09:30:09 +08:00
parent ee2b5585e8
commit 0b00ebaa33
7 changed files with 194 additions and 55 deletions
+159
View File
@@ -0,0 +1,159 @@
# Created by https://www.gitignore.io/api/vim,linux,python
# Edit at https://www.gitignore.io/?templates=vim,linux,python
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
### Python Patch ###
.venv/
### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
# End of https://www.gitignore.io/api/vim,linux,python
+2 -5
View File
@@ -6,7 +6,8 @@ Status:
- [x] turn off touchscreen when using pen
- [ ] turn off touchpad and trackpoint in tablet mode
- [x] Changed to use acpi hook since it lacks hotkey
- [ ] BUG: doesn't always fire
- [ ] BUG: doesn't always fire
- [x] I'm adding this to startup `/usr/bin/acpi_listen | /opt/thinkpad-x380-yoga-scripts/tablet/acpi_tablet_monitor.sh`
- [x] BUG: touchpad wont enable again, this seems to be a driver bug
forked from :https://github.com/ffejery/thinkpad-l380-yoga-scripts
@@ -48,10 +49,6 @@ sudo systemctl status yoga-rotate@${USER}.service
sudo systemctl enable yoga-tablet.service
sudo systemctl start yoga-tablet.service
sudo systemctl status yoga-tablet.service
# install acpi hooks (since the tablet mode acpi doesn't seem to register as a hotkey on the x380)
sudo cp -r ./tablet/* /etc/acpi/
```
# Scripts should fix:
+5 -2
View File
@@ -4,12 +4,15 @@ Requires=display-manager.service
After=display-manager.service
[Service]
ExecStart=/bin/bash /opt/thinkpad-x380-yoga-scripts/tablet/mouse-toggle.sh
ExecStart=/bin/bash -c '/usr/bin/acpi_listen | /opt/thinkpad-x380-yoga-scripts/tablet/acpi_tablet_monitor.sh'
KillMode=process
Environment="DISPLAY=:0"
Type=forking
Type=simple
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
while true ; do
read ACPI_EVENT
case "$ACPI_EVENT" in
"ibm/hotkey IBM0068:00 00000080 0000500c")
echo "Stylus removed"
;;
"ibm/hotkey IBM0068:00 00000080 0000500b")
echo "Stylus replaced"
;;
"video/tabletmode TBLT 0000008A 00000001")
xinput disable "ETPS/2 Elantech TrackPoint"
synclient TouchpadOff=1
nohup onboard >/dev/null 2>&1 &
echo "Tablet mode"
;;
"video/tabletmode TBLT 0000008A 00000000")
xinput enable "ETPS/2 Elantech TrackPoint"
synclient TouchpadOff=0
killall onboard
echo "Normal mode"
;;
*)
echo "Unknown event: '$ACPI_EVENT'"
;;
esac
done
-5
View File
@@ -1,5 +0,0 @@
# /etc/acpi/events/thinkpad-tablet-disabled
# This is called when the lid is placed in normal position on
# Lenovo ThinkPad X380 Tablet
event=video/tabletmode TBLT 0000008A 00000000
action=/etc/acpi/mouse-toggle.sh on
-6
View File
@@ -1,6 +0,0 @@
# /etc/acpi/events/thinkpad-tablet-enabled
# This is called when the lid is placed in tablet position on
# Lenovo ThinkPad X380 Tablet
event=video/tabletmode TBLT 0000008A 00000001
action=/etc/acpi/mouse-toggle.sh off
-37
View File
@@ -1,37 +0,0 @@
#!/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/ffejery/thinkpad-x380-yoga-scripts
#
# Originally from AdmiralAkber:
# https://github.com/admiralakber/thinkpad-yoga-scripts
# Author: AdmiralAkber
case "$1" in
off)
logger "Tablet mode on, mouse $1"
# TODO do touchpad buttons
# Trackpoint includes the red joystick and also the mouse buttons
xinput disable "ETPS/2 Elantech TrackPoint"
# BUG workaround: using xinput to turn the touchpad off works, but I can't turn it back on without restarting. synclient works however.
#xinput disable "ETPS/2 Elantech Touchpad"
synclient TouchpadOff=1
nohup onboard >/dev/null 2>&1 &
;;
on)
logger "Tablet mode off, mouse $1"
# for some reason this isn't working, we can't enable the touchpad again!
#xinput enable "ETPS/2 Elantech Touchpad"
xinput enable "ETPS/2 Elantech TrackPoint"
synclient TouchpadOff=0
killall onboard
;;
*)
logger "ACPI action undefined: $1"
;;
esac