Skip to content

Detect if your laptop is in normal or tablet mode. Useful for Yoga laptops to disable keyboard/trackpoint/touchpad in a tablet mode

License

Notifications You must be signed in to change notification settings

gcala/linux_detect_tablet_mode

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Tablet mode detection and setup scripts for linux

What it does

It uses monitor-sensor from iio-sensor-proxy to detect switches for three modes:

  • normal
  • tablet lanscape
  • table portrait

and executes commands for switching into that mode, which are specified in a config file. Generally you would put there commands to disable/enable a keyboard/touchpad/trackpoint, show/hide an on-screen keyboard, toggle some desktop environment panels, and the like.

Supported devices

All devices that have a tablet mode switch supported by libinput. As far as I understand this is a standard mechanism for this functionality nowadays. Tested devices:

  • Teclast F6 Pro

If it works on your device, please tell me and I'll add it to the list (or just submit a pull request yourself).

Installation

  1. Install ruby and stdbuf (most likely you already have them preinstalled)
  2. Clone it somewhere, and optionally symlink watch_tablet into any directory in your $PATH
  3. Copy a config file into ~/.config/watch_tablet.yml
  4. Adjust the config (see below)
  5. Add watch_tablet & to your ~/.xinitrc
  6. Restart your desktop session and enjoy

Configuration

input_device is a path to the device that provides the tablet mode switch. To find it you may run stdbuf -oL libinput debug-events|grep switch and notice something like event4 in the leftmost column. That would correspond to /dev/input/event4. Device numbers may be unstable across reboots, so you may consider doing ls -lh /dev/input/by-path and finding a symlink to that device. For X1 Yoga Gen2 it's /dev/input/by-path/platform-thinkpad_acpi-event.

modes.laptop, modes.tablet-lanscape, modes.table-portrait - these contain commands that will be executed when mode changes. Most likely this will contain xinput enable and xinput disable commands to enable/disable kb/touchpad/trackpoint (just run xinput to look them up). You may use any other commands to adjust your desktop environment (e.g. hide or show additional panels, increase button size, hide/show onscreen keyboard etc.)

Example:

input_device: /dev/input/by-path/platform-thinkpad_acpi-event
modes:
  laptop:
    # - xinput enable "Wacom Pen and multitouch sensor Finger"
    - xinput enable "AT Translated Set 2 keyboard"
    - xinput enable "SynPS/2 Synaptics TouchPad"
    - xinput enable "TPPS/2 IBM TrackPoint"
  tablet:
    # - xinput disable "Wacom Pen and multitouch sensor Finger"
    - xinput disable "AT Translated Set 2 keyboard"
    - xinput disable "SynPS/2 Synaptics TouchPad"
    - xinput disable "TPPS/2 IBM TrackPoint"

About

Detect if your laptop is in normal or tablet mode. Useful for Yoga laptops to disable keyboard/trackpoint/touchpad in a tablet mode

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%