From ed6bdc080ae8cca79df208157e725ee0556ed631 Mon Sep 17 00:00:00 2001 From: alejandrogs73 Date: Mon, 28 Sep 2026 13:04:38 +0200 Subject: [PATCH] =?UTF-8?q?slstatus:=20bater=C3=ADa=20del=20dispositivo=20?= =?UTF-8?q?bluetooth=20conectado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01C5v1qWDwgkaVM5kjVHGGh8 --- README-en.md | 2 +- README.md | 2 +- suckless/slstatus/config.h | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README-en.md b/README-en.md index 12ee707..37a61dc 100644 --- a/README-en.md +++ b/README-en.md @@ -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 | | | 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 | -| 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`) | | | | After changing dwm's `config.h`, reinstall and restart it for new clicks to diff --git a/README.md b/README.md index 2eaa5f4..9f3360e 100644 --- a/README.md +++ b/README.md @@ -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 | | | 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 | -| 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`) | | | | Si se cambia el `config.h` de dwm, hay que reinstalarlo y reiniciarlo para diff --git a/suckless/slstatus/config.h b/suckless/slstatus/config.h index 314de23..4482779 100644 --- a/suckless/slstatus/config.h +++ b/suckless/slstatus/config.h @@ -52,8 +52,11 @@ static const struct arg args[] = { /* 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\" }'; " "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; }; " - "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" }, };