moved all desktop utils into this repo
This commit is contained in:
parent
cd7e93374e
commit
2241d30a86
28 changed files with 151 additions and 45 deletions
23
ewwScripts/bluetooth.sh
Executable file
23
ewwScripts/bluetooth.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Get the list of connected Bluetooth devices
|
||||
devices=$(bluetoothctl devices Connected | awk '{print $2}')
|
||||
name[0]=""
|
||||
battery[0]=0
|
||||
i=0
|
||||
# Iterate through each device and get its name and battery percentage
|
||||
for device in $devices; do
|
||||
|
||||
# Get the device info using bluetoothctl
|
||||
info=$(bluetoothctl info "$device")
|
||||
|
||||
# Extract the name and battery percentage from the device info
|
||||
name[i]=$(echo "$info" | awk '/Name:/ {for(i=2; i<=NF; i++) printf "%s ", $i;}')
|
||||
battery[i]=$(echo "$info" | awk '/Battery Percentage:/ {print $4}' | tr -d '()')
|
||||
|
||||
|
||||
|
||||
((i=i+1))
|
||||
done
|
||||
|
||||
echo '{"name":"'"${name[0]}"'","battery":"'"${battery[0]}"'"}'
|
Loading…
Add table
Add a link
Reference in a new issue