Skip to content

tomstrong64/tablet-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux Tablet Mode Controller

This service detects when the laptop screen is folded over for use as a tablet and enables screen auto rotation, this is reverted when the laptop screen is folded back into the normal position.

This has only been tested and proven working on a Lenovo Ideapad Flex 5 with Linux Mint installed. Help is welcome to improve the compatibility with other devices.

Setup

Install the debian package, then run the service as the user:

systemctl --user daemon-reload
systemctl --user start tablet-mode.service
systemctl --user enable tablet-mode.service

How it works

I went through the events in /dev/input, running cat inputX | od -x --width=24 and folding the screen back and forth until one produced an output at the time of folding to tablet mode and folding it back.

Below was the output of event10:

event10 output

The output was consitent to this format, so I wrote the code to watch the output for the 0x42 and 0x43 values to determine which state it should be in. When it detects the laptop to be in tablet mode, it runs the following command to turn off screen orientation lock:

gsettings set org.cinnamon.settings-daemon.peripherals.touchscreen orientation-lock false

When it detects the laptop lid is opened, it runs the following 2 commands to enable screen orientation lock and to set the screen orientation to normal:

gsettings set org.cinnamon.settings-daemon.peripherals.touchscreen orientation-lock true
xrandr -o normal

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published