fix: Razer Naga Swap - Daemonisierung entfernt (systemd managed)
- Doppeltes fork/setsid raus (systemd Type=simple daemonisiert selbst) - Debug-Test-Code entfernt (war nur für initiale Fehlersuche) - PID-File entfernt (nicht nötig bei systemd) - Script läuft jetzt sauber als foreground-Prozess
This commit is contained in:
parent
9faf944870
commit
e03470ec0f
1 changed files with 2 additions and 35 deletions
|
|
@ -1,12 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Razer Naga Left Handed Edition - Button Swapper
|
||||
Debug version - shows which code fails.
|
||||
Swaps left/right mouse buttons via evdev/uinput.
|
||||
Runs as a systemd service (Type=simple) — no daemonization.
|
||||
"""
|
||||
import evdev
|
||||
from evdev import UInput, ecodes as e
|
||||
import sys
|
||||
import os
|
||||
|
||||
VENDOR = 0x1532
|
||||
PRODUCT = 0x008d
|
||||
|
|
@ -38,29 +38,6 @@ def main():
|
|||
naga = evdev.InputDevice(naga_path)
|
||||
naga.grab()
|
||||
|
||||
# Try each code individually to find the bad one
|
||||
test_caps = {
|
||||
e.EV_KEY: [e.BTN_LEFT, e.BTN_RIGHT],
|
||||
e.EV_REL: [e.REL_X, e.REL_Y],
|
||||
}
|
||||
|
||||
for etype, codes in test_caps.items():
|
||||
for code in codes:
|
||||
try:
|
||||
ui = UInput(
|
||||
name=UINPUT_NAME,
|
||||
vendor=VENDOR,
|
||||
product=PRODUCT,
|
||||
version=1,
|
||||
bustype=0x03,
|
||||
events={etype: [code]},
|
||||
)
|
||||
ui.close()
|
||||
print(f"OK: type={etype} code={code}", file=sys.stderr)
|
||||
except Exception as ex:
|
||||
print(f"FAIL: type={etype} code={code}: {ex}", file=sys.stderr)
|
||||
|
||||
# Now create the real one with only working codes
|
||||
caps = {
|
||||
e.EV_KEY: [e.BTN_LEFT, e.BTN_RIGHT],
|
||||
e.EV_REL: [e.REL_X, e.REL_Y],
|
||||
|
|
@ -75,17 +52,7 @@ def main():
|
|||
events=caps,
|
||||
)
|
||||
|
||||
# Fork to background
|
||||
if os.fork() > 0:
|
||||
sys.exit(0)
|
||||
os.setsid()
|
||||
if os.fork() > 0:
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
with open("/var/run/razer-naga-swap.pid", "w") as f:
|
||||
f.write(str(os.getpid()))
|
||||
|
||||
for event in naga.read_loop():
|
||||
if event.type == e.EV_KEY:
|
||||
if event.code == e.BTN_LEFT:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue