You can use xinput
to restrict input devices to certain displays. I've got a touchscreen that, by default, think the touch area is the combined desktop span instead of just the external one. So I just lock the touch input devices to that.
Use xinput list
and find the device IDs (id=XXX
) for the mouse/keyboard you want to map to your secondary display.
Then use xrandr --query
to list the monitor names (eDP-1, DP-1, HDMI-1, etc)
Finally, map the devices to that output as such: xinput map-to-output {ID} {DISPLAY}
e.g. if my keyboard input id is 9, and my mouse id is 10, and I want them to go to my external display witch is DP-1
:
xinput map-to-output 9 DP-1
and xinput map-to-output 10 DP-1
The devices IDs are dynamic, and these are not persistent, so you'd probably want to script it to find them and automatically do the mapping.