updated base path and added tooltip
This commit is contained in:
@@ -1,25 +1,29 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Path to your Razer HID battery info
|
# Path to your Razer HID battery info
|
||||||
BASE="/sys/bus/hid/drivers/razermouse/0003:1532:00AB.000A"
|
#BASE="/sys/bus/hid/drivers/razermouse/0003:1532:00AB.000A"
|
||||||
|
BASE="/sys/devices/pci0000:00/0000:00:01.2/0000:02:00.0/usb1/1-8/1-8.1/1-8.1.2/1-8.1.2:1.0/0003:1532:00AB.0009"
|
||||||
|
|
||||||
# Read raw level and charging status
|
# Read raw level and charging status
|
||||||
raw=$(cat "${BASE}/charge_level")
|
raw=$(cat "$BASE/charge_level")
|
||||||
status=$(cat "${BASE}/charge_status") # 1=charging, 0=not charging
|
status=$(cat "$BASE/charge_status") # 1=charging, 0=not charging
|
||||||
|
type=$(cat "$BASE/device_type")
|
||||||
|
|
||||||
# Compute %
|
# Compute %
|
||||||
percent=$(( raw * 100 / 255 ))
|
percent=$(( raw * 100 / 255 ))
|
||||||
|
|
||||||
|
tooltip="$type"
|
||||||
|
|
||||||
# Choose icon + class
|
# Choose icon + class
|
||||||
if [[ $status -eq 1 ]]; then
|
if [[ $status -eq 1 ]]; then
|
||||||
icon="⚡" # charging icon
|
icon="⚡"
|
||||||
cls="charging"
|
cls="charging"
|
||||||
text="${icon} ${percent}%"
|
text="$icon $percent%"
|
||||||
else
|
else
|
||||||
cls="not_charging"
|
cls="not_charging"
|
||||||
text="${percent}%"
|
text="$percent%"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output Waybar‐friendly JSON
|
# Output Waybar‐friendly JSON
|
||||||
printf '{"text":"%s","class":"%s"}\n' "$text" "$cls"
|
printf '{"text":"%s","class":"%s","tooltip":"%s"}\n' "$text" "$cls" "$tooltip"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user