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

@@ -18,6 +18,7 @@
"pulseaudio",
"network",
"battery",
"custom/razer-mouse-battery",
"tray",
"clock",
],
@@ -124,7 +125,7 @@
"default": ["", ""],
},
"scroll-step": 5,
"on-click": "pwvucontrol",
"on-click": "pavucontrol",
"ignored-sinks": ["Easy Effects Sink"],
},
"privacy": {
@@ -164,7 +165,7 @@
},
"bluetooth": {
"format": " {status}",
"on-click": "overskride",
//"on-click": "",
"format-connected": " {device_alias}",
"format-connected-battery": " {device_alias} {device_battery_percentage}%",
"tooltip-format": "{controller_alias}\t{controller_address}\n\n{num_connections} connected",
@@ -180,4 +181,10 @@
"tooltip": true,
"format": "{text}",
},
"custom/razer-mouse-battery": {
"format": "{text}",
"return-type": "json",
"exec": "$HOME/.config/waybar/scripts/razer_basilisk_v3_pro_battery_info.sh",
"interval": 10,
},
}

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"

View File

@@ -205,3 +205,14 @@ tooltip label {
#custom-alhp.down {
border-bottom: 1px solid #800000;
}
#custom-razer-mouse-battery {
padding-left: 5px;
padding-right: 5px;
}
#custom-razer-mouse-battery.charging {
border-bottom: 1px solid #adff2f;
}
#custom-razer-mouse-battery.not_charging {
border-bottom: 1px solid #f6ac00;
}