• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Tablet mode detection and setup scripts for linux

What it does

It uses libinput debug-events to detect switches to normal and tablet mode, 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:

  • ThinkPad X1 Yoga Gen2 (it was developed for it)
  • Thinkpad X1 Yoga Gen3
  • Thinkpad X1 Yoga Gen4
  • Thinkpad Yoga 11e Gen6
  • Lenovo IdeaPad Flex 5i Gen 7
  • Samsung Galaxy Book Flex2 5G

If it works on your device, please tell me and I'll add it to the list (or just submit a pull request yourself). To check if your device is supported, run stdbuf -oL libinput debug-events|grep switch, flip your laptop between normal and tablet mode, and see if it printed anything. If you don't see any switch events, your device will not work with these scripts.

Installation

  1. Add your user to the input group (sudo gpasswd --add username input) and relogin to apply group membership.
  2. Install ruby and stdbuf (most likely you already have them preinstalled)
  3. Clone this repo somewhere, and optionally symlink watch_tablet into any directory in your $PATH
  4. Copy a config file into ~/.config/watch_tablet.yml
  5. Adjust the config (see below)
  6. Test it by running watch_tablet in a terminal and flipping your laptop to tablet and back. You should see commands from the config being executed. Press Ctrl+C to terminate it.
  7. After you confirmed that everything works, add watch_tablet & to your ~/.xinitrc
  8. Restart your desktop session and enjoy

Arch Linux

If you have an Arch-based distribution, you can install it using this AUR package

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 - this 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"

More Repositories

1

git-upstream

Turn a fork that has periodic merges of upstream into easily upstreamable rebaseable linear history (git-imerge rebase through merges)
Shell
22
star
2

vkpd

VKPD searches vk.com for music files and plays them via mpd
Ruby
17
star
3

live-components

Don't duplicate server state on the client and get realtime collaboration for free
Clojure
9
star
4

gravatar-clj

Clojure and ClojureScript library to generate gravatar links
Clojure
6
star
5

zenbook-duo-2024-ux8406ma-linux

automatic screen on/off, brightness sync, battery limiter
Shell
6
star
6

cv

My CV
TeX
5
star
7

my-hipchat

CoffeeScript
5
star
8

cljs-npm-bundle

Bundle NPM deps for use from ClojureScript via :foreign-libs
Makefile
5
star
9

arvo-commander

Midnight commander clone in clojurescript, reagent, nodejs and react-blessed
Clojure
4
star
10

slice

Write HTML/CSS interactively
Clojure
3
star
11

noapi

Library to expose clojure namespaces as HTTP API
Clojure
3
star
12

back_to_work

Locks computer if you are wasting time. Get some rest and come back to work.
Shell
3
star
13

home

My /home
Common Lisp
3
star
14

erlang-otp-demo

Just demo erlang application i wrote for an interview. Uses OTP and Yaws.
Erlang
3
star
15

.emacs.d

my old emacs config
Emacs Lisp
2
star
16

hazelcast-atom

A Clojure library implementing distributed atoms on top of Hazelcast
Clojure
2
star
17

cl-term

Use ansi escape sequences to control terminal (move cursor, set colors etc.)
Common Lisp
2
star
18

jpen

JPen is a java library for accessing pen/digitizer tablets and pointing devices
Java
2
star
19

ruby_is

ruby syntax extension: double is {|x| x*2}; fib is memoized {|n| n<2 ? 1 : fib(n-2)+fib(n-1)}
Ruby
2
star
20

fn-syntax

Lambda shorthand: fn{ _1 * 2 } instead of lambda{|x| x*2}
Ruby
2
star
21

cinema

Select movie from trakt.tv watchlist and stream it from torrents
Ruby
1
star
22

harmony

Ruby
1
star
23

plurked

Daemon which monitors your twitter account and reposts new tweets to your plurk.
Ruby
1
star
24

bash-voice-notes

Records, stores, plays and translates voice notes to text
Shell
1
star
25

mashpitario

GameDev Startup 2011 Mash Pit project
JavaScript
1
star
26

clide

Clojure reimplementation of Aelve Guide
Clojure
1
star
27

screenlog

Take screenshots every 10 minutes and annotate filenames with some text. Useful for work time tracking as ad-hoc replacement for oDesk Team.
Shell
1
star