diff --git a/src/scripts/python/changemouse.py b/src/scripts/python/changemouse.py new file mode 100755 index 0000000..2f18a7c --- /dev/null +++ b/src/scripts/python/changemouse.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +"""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: master "touch-pointer" should be available on the event of adding the + mouse. This could be reached by adding this master to the system on boot. + + 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 xutil.pointer as xup +import xutil.common as com + +if __name__ == "__main__": + # If we didn't import the script as utility + pointers = xup.get_pointers() + # TODO filter functionality inside utilities + core_master = list(filter(lambda x: "Virtual core" in x.name, pointers))[0] + for pointer in filter(lambda x: not x.slave, pointers): + if not "eGalax" in pointer.name: + com.reattach(pointer.id, core_master.id) + else: + # TODO: add touchpannel support + pass