New backup 2025-03-04 17:30:02
This commit is contained in:
parent
057262ef5d
commit
ec9ea05eca
1 changed files with 6 additions and 3 deletions
|
@ -1,11 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
device_mac_list=$(bluetoothctl devices Paired | awk '{print $2}')
|
||||
device_json_array=()
|
||||
|
||||
for m in ${device_mac_list};do
|
||||
device_name="$(bluetoothctl info ${m} | grep 'Name: ' | sed 's/.*Name: //')"
|
||||
device_icon="$(bluetoothctl info ${m} | grep 'Icon: ' | sed 's/.*Icon: //')"
|
||||
echo "mac: ${m}"
|
||||
device_json=$( jq -n --arg name "${device_name}" --arg icon "${device_icon}" --arg address "${m}" '{name: $name, icon: $icon, address: $address}')
|
||||
device_json_array+=(${device_json})
|
||||
done
|
||||
#devices=$(echo '[{"name":"mouse"},{"name":"headphones"}]' | jq '.')
|
||||
#echo ${devices}
|
||||
devices=$(echo "${device_json_array[@]}" | jq '.')
|
||||
#(echo '[{"name":"mouse"},{"name":"headphones"}]' | jq '.')
|
||||
echo ${devices}
|
||||
|
|
Loading…
Add table
Reference in a new issue