dot
vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks
| 1 | #!/usr/bin/env bash |
| 2 | # Battery of a wireless Logitech mouse (G Pro X Superlight) as one line of JSON. |
| 3 | # Used by the Eww control center (and by a Waybar custom module if you re-add one). |
| 4 | # When the mouse isn't found: "connected":false and an empty "text" (Waybar hides the module). |
| 5 | # |
| 6 | # Source 1: the kernel's HID++ driver, which exposes the mouse under |
| 7 | # /sys/class/power_supply/hidpp_battery_N (the number changes between |
| 8 | # reconnects, so we glob instead of hardcoding it). |
| 9 | # Source 2: Solaar (`solaar show`), used only if source 1 finds nothing. |
| 10 | # |
| 11 | # MOUSE_MATCH is matched (case-insensitive) against the device name. |
| 12 | |
| 13 | MATCH="" |
| 14 | cap=""; status=""; name="" |
| 15 | |
| 16 | for; do |
| 17 | [ || continue |
| 18 | model= |
| 19 | if [ || | ; then |
| 20 | c= |
| 21 | if [; then |
| 22 | cap= |
| 23 | status= |
| 24 | name= |
| 25 | fi |
| 26 | fi |
| 27 | done |
| 28 | |
| 29 | if [ && ; then |
| 30 | out= |
| 31 | line= |
| 32 | cap= |
| 33 | status= |
| 34 | name="Logitech mouse (via Solaar)" |
| 35 | fi |
| 36 | |
| 37 | if [; then |
| 38 | |
| 39 | |
| 40 | fi |
| 41 | |
| 42 | # Icon: 5 steps from full to empty (charging gets its own icon). |
| 43 | if [ || [; then icon=""; class="charging" |
| 44 | elif [; then icon=""; class="" |
| 45 | elif [; then icon=""; class="" |
| 46 | elif [; then icon=""; class="" |
| 47 | elif [; then icon=""; class="warning" |
| 48 | else icon=""; class="critical" |
| 49 | fi |
| 50 | |
| 51 | label="%" |
| 52 | [ && label="% · charging" |
| 53 | |
| 54 | |
| 55 | |