Skip to content

Detects and executes commands when the computer switches to and from tablet mode.

License

Notifications You must be signed in to change notification settings

yehuthi/linuxflip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux Flip

Detects and executes commands when the computer switches to and from tablet mode.

Setup

  1. Download the latest release, or if you're on Arch: yay -S linuxflip-git
  2. Add your user to the input group (unless you want to run it as root -- not recommended).

Tip

⌨ Add yourself to input group

Open the terminal (press Ctrl+Alt+T or find it as you would any other program), and enter:

sudo usermod -a input $USER

Then you can simply run it or hook it to a desktop session startup script.

Usage

Run linuxflip --help for usage options. The one you're probably interested in is:

linuxflip <tablet-cmd> <laptop-cmd>
    Runs <tablet-cmd> in a shell when the mode changes to tablet, and <laptop-cmd> when the mode changes to laptop.
  • The commands run in a shell, so shell features are supported (such as tilde expansion).
  • The commands run asynchronously.

Examples

Scripts

A typical example is running script files. You can place them wherever you want and to run them, the command is simply their path. Set up those scripts however you want and make sure they're executable (chmod +x), then run:

linuxflip "~/.config/linuxflip/tablet" "~/.config/linuxflip/laptop"

Commands

You can pass commands, which can be very handy for trivial setups. For example, if you just want to display an on-screen keyboard:

linuxflip corekeyboard "killall corekeyboard"

Appendix: Disable/Enable Devices

To disable or enable a device, such as a keyboard, the trackpad, etc. use xinput:

xinput disable "device name"
xinput enable "device name"

To find out the device name, you can run xinput list and see if you can definitely spot the device there. If it's not obvious:

  1. Run libinput debug-events. You should see some lines for the connected devices.
  2. Send input from the device (press a button on a keyboard, move the cursor on a mouse, etc.). The terminal should react with new lines.
  3. Note the event number on the first column for the new lines.
  4. Scroll up to the first lines about the connected devices and find the event number there. The third column is the device name.

Now we can disable/enable a device called "device name" on switch by putting the disable/enable commands in the scripts, or directly like this:

linuxflip 'xinput disable "device name"' 'xinput enable "device name"'

Appendix: Run Automatically

  1. Create a file ~/.xsession if doesn't exist
  2. Append your linuxflip command to it, and remember not to block, e.g.
    linuxflip "~/.config/linuxflip/tablet" "~/.config/linuxflip/laptop" &
    (note the & at the end)
  3. Make sure it's executable (chmod +x ~/.xsession)