#!/usr/bin/env python3 """Change mouse script Whenever a mouse is changed to the system, this script will be executed. These are the rules: + All regular mouses should connect to the "Virtual core pointer" of the system + Touchpanel should be connected to the master "touch-pointer" NOTE: if master `touch` is not present in the system, the script will create a master `touch` itself and hides the pointer. eGalax device input will be attached to this master. TODO: make master's cursor invisible. Currently we'll use xinput command-line application, but, It is possible to write a specified c program that uses Xlib efficiently. Steps: + List all pointer as we don't know what pointer is added to the system + group them by their usage by name rules (As if the pointer is eGalax touch pointer it should be attached to the touch-pointer o.w. it should be attached to Vitual core pointer (OR trackball TODO)) utility functions to find and group pointers aer available in xutil module. NOTE: In case of psyco adds and removes mouses with intervals smaller than run time of this code (which is not probabale at all) a lockfile is used so that only one instance of this code is running at a moment so no conflicts occur. """ import util.pointer as putil import util.x as xutil if __name__ == "__main__": """Configure Pointers Execution time: 140ms avg -> Tolarable """ v_core, touch_master, e_galax, pointers = putil.get_pointers_categorized() if e_galax: xutil.reattach(e_galax.id, touch_master.id) else: # TODO: disable touch? pass for p in pointers: xutil.reattach(p.id, v_core.id)