slstatus: batería del dispositivo bluetooth conectado

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C5v1qWDwgkaVM5kjVHGGh8
This commit is contained in:
Alejandro Guerrero 2026-09-28 13:04:38 +02:00
parent 7f0137d734
commit ed6bdc080a
Signed by: alejandrogs73
GPG key ID: 1CFF10953BEE333C
3 changed files with 7 additions and 4 deletions

View file

@ -162,7 +162,7 @@ and which area is which is marked by the `\001`...`\004` bytes in
| Network | `ETH` on cable; otherwise `WiFi:` and the network | `wifi` menu: networks by signal, connect, ask for and save the password | | `wpa_cli` in a floating st | | | Network | `ETH` on cable; otherwise `WiFi:` and the network | `wifi` menu: networks by signal, connect, ask for and save the password | | `wpa_cli` in a floating st | |
| BAT | Percentage and state (`+` charging, `-` discharging) | | | | | | BAT | Percentage and state (`+` charging, `-` discharging) | | | | |
| VOL | Volume; `MUT` if muted, `MIC OFF` if the mic is | Pick the audio output (`volumen salida`) | Mute | Mute the mic | Up / down | | VOL | Volume; `MUT` if muted, `MIC OFF` if the mic is | Pick the audio output (`volumen salida`) | Mute | Mute the mic | Up / down |
| BT | `OFF`, or the connected device | `bluetooth` menu: connect, disconnect, scan and pair, power off | | Power on or off | | | BT | `OFF`, or the connected device and its battery if it reports it (`VJ 901 100%`) | `bluetooth` menu: connect, disconnect, scan and pair, power off | | Power on or off | |
| Date | Day and time | This month's calendar (`calendario`) | | | | | Date | Day and time | This month's calendar (`calendario`) | | | |
After changing dwm's `config.h`, reinstall and restart it for new clicks to After changing dwm's `config.h`, reinstall and restart it for new clicks to

View file

@ -160,7 +160,7 @@ y qué zona es cada una lo marcan los bytes `\001`...`\004` de
| Red | `ETH` con cable; si no, `WiFi:` y la red | Menú `wifi`: redes por señal, conectar, pedir y guardar la contraseña | | `wpa_cli` en una st flotante | | | Red | `ETH` con cable; si no, `WiFi:` y la red | Menú `wifi`: redes por señal, conectar, pedir y guardar la contraseña | | `wpa_cli` en una st flotante | |
| BAT | Porcentaje y estado (`+` cargando, `-` descargando) | | | | | | BAT | Porcentaje y estado (`+` cargando, `-` descargando) | | | | |
| VOL | Volumen; `MUT` si está silenciado, `MIC OFF` si el micro lo está | Elegir la salida de audio (`volumen salida`) | Silenciar | Silenciar el micro | Subir / bajar | | VOL | Volumen; `MUT` si está silenciado, `MIC OFF` si el micro lo está | Elegir la salida de audio (`volumen salida`) | Silenciar | Silenciar el micro | Subir / bajar |
| BT | `OFF`, o el dispositivo conectado | Menú `bluetooth`: conectar, desconectar, buscar y emparejar, apagar | | Encender o apagar | | | BT | `OFF`, o el dispositivo conectado y su batería si la da (`VJ 901 100%`) | Menú `bluetooth`: conectar, desconectar, buscar y emparejar, apagar | | Encender o apagar | |
| Fecha | Día y hora | Calendario del mes (`calendario`) | | | | | Fecha | Día y hora | Calendario del mes (`calendario`) | | | |
Si se cambia el `config.h` de dwm, hay que reinstalarlo y reiniciarlo para Si se cambia el `config.h` de dwm, hay que reinstalarlo y reiniciarlo para

View file

@ -52,8 +52,11 @@ static const struct arg args[] = {
/* mismo volumen que maneja wpctl (PipeWire); MIC OFF si el micro está silenciado */ /* mismo volumen que maneja wpctl (PipeWire); MIC OFF si el micro está silenciado */
{ run_command, "\002[ VOL: %s ]\002 ", "wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{ printf \"%d%%\", $2 * 100 + 0.5 } /MUTED/ { printf \" MUT\" }'; " { run_command, "\002[ VOL: %s ]\002 ", "wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{ printf \"%d%%\", $2 * 100 + 0.5 } /MUTED/ { printf \" MUT\" }'; "
"wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep -q MUTED && printf ' MIC OFF'" }, "wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep -q MUTED && printf ' MIC OFF'" },
/* OFF si el adaptador está apagado; si no, el primer dispositivo conectado */ /* OFF si el adaptador está apagado; si no, el primer dispositivo conectado
* y su batería, si la da ("Battery Percentage: 0x64 (100)" -> " 100%") */
{ run_command, "\003[ BT: %s ]\003 ", "bluetoothctl show | grep -q 'Powered: yes' || { echo OFF; exit; }; " { run_command, "\003[ BT: %s ]\003 ", "bluetoothctl show | grep -q 'Powered: yes' || { echo OFF; exit; }; "
"bluetoothctl devices Connected | head -1 | cut -d' ' -f3-" }, "set -- $(bluetoothctl devices Connected | head -1); [ $# -gt 0 ] || exit; "
"m=$2; shift 2; printf %s \"$*\"; "
"bluetoothctl info \"$m\" | awk -F'[()]' '/Battery Percentage/ { printf \" %s%%\", $2 }'" },
{ datetime, "\004[ %s ]\004", "%d/%m/%y %H:%M" }, { datetime, "\004[ %s ]\004", "%d/%m/%y %H:%M" },
}; };