Linux – Multiple keyboard and mouse inputs

keyboardlinuxmouse

I have a linux laptop connected to an external monitor, keyboard and mouse. How can I have the laptop's keyboard and trackpad be independent from the external keyboard and mouse so I can keep them exclusively on the laptop's screen and use the external keyboard and mouse primarily on the external monitor?

Best Answer

I found a solution to the problem and I wrote a script to toggle mouse and keyboard splitting:

#!/bin/bash

xinput list | grep "main keyboard" -c > /dev/null

if [ $? -ne 0 ]; then
  echo "Splitting laptop leyboard and touchpad..."
  echo "Creating xinput main"
  xinput create-master "main"
  echo "Reattaching laptop touchpad and keyboard to main"
  xinput reattach "SynPS/2 Synaptics TouchPad" "main pointer"
  xinput reattach "AT Translated Set 2 keyboard" "main keyboard"
else
  echo "Merging laptop keyboard and touchpad..."
  echo "Reattaching laptop touchpad and keyboard to core"
  xinput reattach "SynPS/2 Synaptics TouchPad" "Virtual core pointer"
  xinput reattach "AT Translated Set 2 keyboard" "Virtual core keyboard"
  echo "Removing xinput main"
  xinput remove-master "main keyboard"
fi
Related Question