diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-26 09:07:36 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-26 09:07:36 +0200 |
| commit | 1927badfc173c6d9a32deed9ca7776d987b2ea75 (patch) | |
| tree | edf93fca6be222499beab88b39d70e5e22aa4ccc /examples | |
| parent | 14abc878285d961a90f9e56b85c15a091531f6e5 (diff) | |
| download | desktop-assistant-1927badfc173c6d9a32deed9ca7776d987b2ea75.tar.gz desktop-assistant-1927badfc173c6d9a32deed9ca7776d987b2ea75.zip | |
Read controller batteries, stop the model guessing system facts
- Game controllers report battery through their kernel driver, not
BlueZ: bluetooth.sh falls back to the power supply named after the
device address.
- Asked for a VM's IP after a listing without one, the model made one up
without calling a tool. The default system prompt now says facts about
the user's computer, devices, accounts, mail, calendar or money come
only from a tool, or it says it does not know.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'examples')
| -rwxr-xr-x | examples/tools/bluetooth.sh | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/examples/tools/bluetooth.sh b/examples/tools/bluetooth.sh index a3af0f9..c00c853 100755 --- a/examples/tools/bluetooth.sh +++ b/examples/tools/bluetooth.sh @@ -16,7 +16,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # bluetooth.sh: whether bluetooth is on, the connected devices with their -# kind (BlueZ icon name) and battery when the device reports one, and the +# kind (BlueZ icon name) and battery when it is known, and the # paired devices that are not connected. Only show, devices and info run # here: nothing connects, pairs or scans. @@ -35,7 +35,16 @@ while read -r _ mac _; do if grep -q $'^\tConnected: yes' <<<"$info"; then kind=$(sed -n 's/^\tIcon: //p' <<<"$info") battery=$(sed -n 's/^\tBattery Percentage: .*(\([0-9]*\))$/\1/p' <<<"$info") - echo "connected: $alias (${kind:-unknown kind}${battery:+, battery $battery%})" + # Game controllers report it through their kernel driver instead + # (hid-playstation, hid-sony, hid-nintendo): a power supply named + # after the device's address. + charging="" + for supply in /sys/class/power_supply/*"${mac,,}"*; do + [ -r "$supply/capacity" ] || continue + battery=$(<"$supply/capacity") + [ "$(cat "$supply/status" 2>/dev/null)" = Charging ] && charging=", charging" + done + echo "connected: $alias (${kind:-unknown kind}${battery:+, battery $battery%}$charging)" connected=$((connected + 1)) else others+=("$alias") |
