diff --git a/src/scripts/python/changemouse.py b/src/scripts/python/changemouse.py index 0df91d7..0874671 100644 --- a/src/scripts/python/changemouse.py +++ b/src/scripts/python/changemouse.py @@ -8,8 +8,13 @@ are the rules: system + Touchpanel should be connected to the master "touch-pointer" -NOTE: if master `touch` is not present in the system, - +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 @@ -23,14 +28,15 @@ NOTE: In case of psyco adds and removes mouses with intervals smaller than run 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 +import util.pointer as xup +import util.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: x.slave, pointers): if not "eGalax" in pointer.name: com.reattach(pointer.id, core_master.id) diff --git a/src/scripts/python/xutil/common.py b/src/scripts/python/util/common.py similarity index 81% rename from src/scripts/python/xutil/common.py rename to src/scripts/python/util/common.py index c7c6a86..dee5673 100644 --- a/src/scripts/python/xutil/common.py +++ b/src/scripts/python/util/common.py @@ -54,3 +54,20 @@ def get_ids() -> List[int]: completed = subprocess.run( ['xinput', '--list', '--id-only'], capture_output=True) return list(map(int, completed.stdout.decode(ENCODING).split())) + + +def create_master(name: str = 'touch'): + """Creates master with specified name + + Args: + name (str, optional): name of the master. Defaults to 'touch'. + """ + completed = subprocess.run( + ['xinput create-master', name] + ) + + return completed.returncode + + +def map_to_output(output, device_id): + pass \ No newline at end of file diff --git a/src/scripts/python/xutil/egalax.py b/src/scripts/python/util/egalax.py similarity index 100% rename from src/scripts/python/xutil/egalax.py rename to src/scripts/python/util/egalax.py diff --git a/src/scripts/python/xutil/pointer.py b/src/scripts/python/util/pointer.py similarity index 93% rename from src/scripts/python/xutil/pointer.py rename to src/scripts/python/util/pointer.py index a6afbe1..41fb97f 100644 --- a/src/scripts/python/xutil/pointer.py +++ b/src/scripts/python/util/pointer.py @@ -95,3 +95,12 @@ def get_pointers(is_short=True): else: pass return pointers + + +def get_touch_master(pointers): + """returns Pointer of the master touch pointer + + Args: + pointers (List[Pointes]): list of pointers queried + """ + pass diff --git a/src/scripts/python/xutil/randr.py b/src/scripts/python/util/randr.py similarity index 98% rename from src/scripts/python/xutil/randr.py rename to src/scripts/python/util/randr.py index 5eebf9c..82f6fae 100644 --- a/src/scripts/python/xutil/randr.py +++ b/src/scripts/python/util/randr.py @@ -2,7 +2,7 @@ """RandR Author: Ali Hatami Tajik [hatam](mailto:a.hatam008@gmail.com) -Date: 2023 Mar 04 +Creation Date: 2023 Mar 04 --- This module provides a wrapper utility around xrandr.