From 1927badfc173c6d9a32deed9ca7776d987b2ea75 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 26 Sep 2026 09:07:36 +0200 Subject: 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 --- examples/tools/bluetooth.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'examples/tools/bluetooth.sh') 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") -- cgit v1.2.3