Browse Source

Move files from xutil to util

pull/2/head
Ali Hatami Tajik 2 years ago
parent
commit
611b0da8e6
  1. 14
      src/scripts/python/changemouse.py
  2. 17
      src/scripts/python/util/common.py
  3. 0
      src/scripts/python/util/egalax.py
  4. 9
      src/scripts/python/util/pointer.py
  5. 2
      src/scripts/python/util/randr.py

14
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)

17
src/scripts/python/xutil/common.py → 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

0
src/scripts/python/xutil/egalax.py → src/scripts/python/util/egalax.py

9
src/scripts/python/xutil/pointer.py → 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

2
src/scripts/python/xutil/randr.py → 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.
Loading…
Cancel
Save