style(waybar): cleanup formatting in razer-battery script
This commit is contained in:
1 parent
343d0a20ae
commit
4ce40fd9c3
1 file changed
+18
Executable
+18
@@ -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}\"}"
|
||||
Reference in new issue
Block a user