style(waybar): cleanup formatting in razer-battery script

This commit is contained in:
pyrschtjag committed 2026-10-30 11:12:05 +04:00
1 parent 343d0a20ae
commit 4ce40fd9c3
1 file changed
+18
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
output=$(razer-cli --battery print 2>/dev/null)
charge=$(echo "$output" | grep -oP 'charge:\s*\K\d+')
charging=$(echo "$output" | grep -oP 'charging:\s*\K\w+')
mouse_icon="<span color='#b4befe'>󰍽</span>"
bolt_icon="<span color='#f9e2af'></span>"
if [[ -z "$charge" ]]; then
echo '{"text": "'"$mouse_icon"'", "tooltip": "", "class": ""}'
exit 0
fi
if [[ "$charging" == "True" ]]; then
text="${mouse_icon} ${bolt_icon}"
class="charging"
else
text="${mouse_icon}"
class="idle"
fi
echo "{\"text\": \"${text}\", \"tooltip\": \"\", \"percentage\": ${charge}, \"class\": \"${class}\"}"