Browse Source

Add change mouse script

This script will be attachd to rules corresponding to change action of
mouse/pointer devices. At this time it will gather all pointers add
reattach them to the Virtual core pointer (Overhead of this approach can
be ignored as we will have very limited number of devices and addition
or removal of such devices wouldn't be a common thing.
pull/2/head
Ali Hatami Tajik 2 years ago
parent
commit
1774b48e96
  1. 40
      src/scripts/python/changemouse.py

40
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
Loading…
Cancel
Save