Setting up OpenRazer (for the battery read) reset the mouse's DPI to its 1800 default, exposing that input.accel_profile was never set - Hyprland/libinput default to an adaptive (accelerated) curve, which became noticeable once the DPI changed. accel_profile = "flat" for a linear 1:1 response, which is what was expected all along. New mouse battery pill in the bar (between network and clock), via scripts/mouse_battery.py querying openrazer - hidden entirely if no Razer device is found, so it's a no-op for anyone without one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dujsk9jYfxUVLtb5B8eC94
20 lines
763 B
Python
20 lines
763 B
Python
#!/usr/bin/env python3
|
|
"""Prints the Razer mouse's battery as JSON: {"available": bool, "pct": int,
|
|
"charging": bool, "name": str}. "available" is false (nothing else meaningful in the
|
|
object) if openrazer isn't installed, its daemon isn't reachable, or no device is
|
|
connected - deliberately never raises, since a traceback on stdout would break the
|
|
bar's JSON.parse of this output.
|
|
"""
|
|
import json
|
|
|
|
try:
|
|
from openrazer.client import DeviceManager
|
|
devices = DeviceManager().devices
|
|
if not devices:
|
|
raise RuntimeError("no device")
|
|
d = devices[0]
|
|
print(json.dumps({"available": True, "pct": d.battery_level,
|
|
"charging": d.is_charging, "name": d.name}))
|
|
except Exception:
|
|
print(json.dumps({"available": False}))
|