1. #!/bin/zsh
  2. getid()
  3. {
  4.     xinput list | grep -m 1 "$1" | sed 's/.*=\([^\t]*\).*/\1/'
  5. }
  6.  
  7. MOUSEID1=$(getid "TPPS/2 IBM TrackPoint")
  8.  
  9. if [ -z "$(xinput list | grep '2ndMouse')" ]; then
  10.     xinput create-master 2ndMouse
  11.     SECOND=$(getid 2ndMouse)
  12.     xinput reattach $MOUSEID1 $SECOND
  13. else
  14.     FIRST=$(getid "Virtual core pointer")
  15.     SECOND=$(getid 2ndMouse)
  16.     xinput reattach $MOUSEID1 $FIRST
  17.     xinput remove-master $SECOND
  18. fi