Last active
November 19, 2024 23:33
-
-
Save oVerde/c781646d002d29f8a5afd38e36add538 to your computer and use it in GitHub Desktop.
In Linux devices running GNOME toggles the keyboard and touchpad on and off for a proper tablet mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# toggle tablet mode script | |
# | |
# Toggles the keyboard and touchpad on and off for tablet mode on many devices | |
# PLEASE ENSURE THAT YOU ARE USING GNOME OR RUNNING SOME ONBOARD KEYBOARD APP BEFORE RUNNING THIS SCRIPT. | |
# This toggler a system variable named TABLET_MODE, OFF and then turns it ON | |
# Depends on `notify-send` and `xinput` | |
# if you dont have any: `brew install libnotify xinput` | |
# Must run using `source ./tgTABLETMODE.sh` | |
# would appreciate if anyone could turn this in a GNOME Plugin | |
if [[ $TABLET_MODE == 1 ]]; then | |
xinput | grep 'Touchpad' | cut -d '=' -f 2 | cut -f 1 | while read -r line; do | |
xinput enable $line | |
done | |
xinput | grep 'Keyboard' | cut -d '=' -f 2 | cut -f 1 | while read -r line; do | |
xinput enable $line | |
done | |
gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled false | |
unset TABLET_MODE | |
notify-send "Tablet Mode OFF" -u critical | |
else | |
export TABLET_MODE=1 | |
xinput | grep 'Touchpad' | cut -d '=' -f 2 | cut -f 1 | while read -r line; do | |
xinput disable $line | |
done | |
xinput | grep 'Keyboard' | cut -d '=' -f 2 | cut -f 1 | while read -r line; do | |
xinput disable $line | |
done | |
gsettings set org.gnome.desktop.a11y.applications screen-keyboard-enabled true | |
notify-send "Tablet Mode ON" -u critical | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you have an OSK solution, you can comment lines
37
and22
, there the script forces it so you can get your kb/tp back on. It will cause some drawback like the OSK showing all the time even when out of Tablet Mode. This does fix when you restart, and is a know GNOME bug.