bluetoothctl:列出连接的设备?

Tiw*_*nty 7 linux bluetooth kubuntu ubuntu

我试图在 Kubuntu 上的 CLI 中获取已连接 BT 设备的列表,但我似乎无法找到方法。

当我启动bluetoothctl它时,它默认为最新连接的设备,我需要断开它才能显示另一个。

有没有办法列出连接的BT设备?

小智 18

这是一个鱼壳单行(参见下面的bash

bluetoothctl devices | cut -f2 -d' ' | while read uuid; bluetoothctl info $uuid; end|grep -e "Device\|Connected\|Name"
Run Code Online (Sandbox Code Playgroud)

bash一行:

bluetoothctl devices | cut -f2 -d' ' | while read uuid; do bluetoothctl info $uuid; done|grep -e "Device\|Connected\|Name"
Run Code Online (Sandbox Code Playgroud)


小智 5

您可以列出已配对的设备bluetoothctl paired-devices

从此列表中,您可以获取每个设备的信息,并bluetoothctl info 在信息中显示“已连接”状态。

因此,在每个设备上循环 grep for Connected: yesif so 显示名称:

bluetoothctl paired-devices | cut -f2 -d' '|
while read -r uuid
do
    info=`bluetoothctl info $uuid`
    if echo "$info" | grep -q "Connected: yes"; then
       echo "$info" | grep "Name"
    fi
done
Run Code Online (Sandbox Code Playgroud)


小智 2

这可能会有所帮助:sudo bluetoothctl info MAC-ADDRESS-OF-DEVICE

  • 我收到“缺少设备地址参数” (2认同)
  • @Swedgin 这意味着您没有连接的设备。 (2认同)
  • @CarlWalsh,该错误准确地告诉您缺少什么:`bluetoothctl info`提供有关_单个_设备的信息,因此您需要告诉它您想要获取信息的设备的MAC地址。 (2认同)