added script to display razer mouse battery

This commit is contained in:
2025-06-28 15:36:14 +02:00
parent ca357f2771
commit 011a90f465
3 changed files with 45 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Path to your Razer HID battery info
BASE="/sys/bus/hid/drivers/razermouse/0003:1532:00AB.000A"
# Read raw level and charging status
raw=$(cat "${BASE}/charge_level")
status=$(cat "${BASE}/charge_status") # 1=charging, 0=not charging
# Compute %
percent=$(( raw * 100 / 255 ))
# Choose icon + class
if [[ $status -eq 1 ]]; then
icon="⚡" # charging icon
cls="charging"
text="${icon} ${percent}%"
else
cls="not_charging"
text="${percent}%"
fi
# Output Waybarfriendly JSON
printf '{"text":"%s","class":"%s"}\n' "$text" "$cls"