Simple bluetooth status #614
ToxicMushroom
started this conversation in
Show and tell
Replies: 2 comments 3 replies
-
@ToxicMushroom Thanks so much for posting this - it really helped me to get started. I managed to figure out the battery part via Prime451's answer here. I have adapted your script to fit in with my use-case and paste it here in case it is useful to anyone else coming across this thread. #!/usr/bin/env bash
BLU_CNT_CONTROLLER=$(ls /sys/class/bluetooth | wc -l)
if [[ $BLU_CNT_CONTROLLER -gt 0 ]]
then
BLU_POWER=$(bluetoothctl show | grep -q 'Powered: yes$'; echo "$?")
if [[ $BLU_POWER -eq 0 ]]
then
BLU_CONNECTED=$(bluetoothctl devices Connected | cut -d ' ' -f3-)
BLU_CONNECTED_MAC=$(bluetoothctl devices Connected | cut -d ' ' -f2)
DEV_BATTERY=$(echo "info $BLU_CONNECTED_MAC" | bluetoothctl | sed -n '/Battery Percentage:/ s/.*(\([0-9]*\).*/\1/p')
if [[ $BLU_CONNECTED != "" ]]
then
echo " $BLU_CONNECTED $DEV_BATTERY%"
else
echo " None"
fi
else
echo " Off"
fi
else
echo " No controller"
fi |
Beta Was this translation helpful? Give feedback.
1 reply
-
Here's a shot of the middle to right side so far. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hope this helps some people to serve as a starting point or inspiration.
Sadly I couldn't get battery level readings reliably
Sorry for the noob bash style/practices
Connected
Powered on, not connected
Powered off
No controller (like unplugging your adapter)
The icons used require a nerdfont
Beta Was this translation helpful? Give feedback.
All reactions