Browse Source

Fix mouse change bug

BUG: script does not take effect when script is run

---
Test Scenario: Two mouse are attached to the different masters and
then we execute the script
Expected Behavior: both mouses reattach to the Virtual core
Problem: filter in the for-loop gathered all masters not slaves
pull/2/head
Ali Hatami Tajik 2 years ago
parent
commit
dc9db72e57
  1. 2
      src/scripts/python/changemouse.py
  2. 6
      src/scripts/python/xutil/pointer.py

2
src/scripts/python/changemouse.py

@ -32,7 +32,7 @@ if __name__ == "__main__":
pointers = xup.get_pointers() pointers = xup.get_pointers()
# TODO filter functionality inside utilities # TODO filter functionality inside utilities
core_master = list(filter(lambda x: "Virtual core" in x.name, pointers))[0] core_master = list(filter(lambda x: "Virtual core" in x.name, pointers))[0]
for pointer in filter(lambda x: not x.slave, pointers): for pointer in filter(lambda x: x.slave, pointers):
if not "eGalax" in pointer.name: if not "eGalax" in pointer.name:
com.reattach(pointer.id, core_master.id) com.reattach(pointer.id, core_master.id)
else: else:

6
src/scripts/python/xutil/pointer.py

@ -37,6 +37,10 @@ class Pointer(XInput):
def __init__(self, name, id, is_master: bool) -> None: def __init__(self, name, id, is_master: bool) -> None:
super().__init__(name, id, is_master) super().__init__(name, id, is_master)
@property
def slave(self):
return not self.is_master
def get_short_pointer(id) -> Pointer: def get_short_pointer(id) -> Pointer:
"""Generates Pointer object corresponding to id (short attrs) """Generates Pointer object corresponding to id (short attrs)
@ -57,7 +61,7 @@ def get_short_pointer(id) -> Pointer:
is_master = "master" in props is_master = "master" in props
return Pointer( return Pointer(
name.strip(), name.strip(),
props.split(maxsplit=1), props.split(maxsplit=1)[0],
is_master) is_master)
else: else:
raise TypeError(f'id[{id}] is not a pointer id') raise TypeError(f'id[{id}] is not a pointer id')

Loading…
Cancel
Save