pacman -S bluez bluez-utils bluez-firmware pulseaudio-bluetooth pavucontrol pulseaudio-alsa
其中:
systemctl enable bluetooth
systemctl start bluetooth
pulseaudio -k # 确保没有pulseaudio启动
pulseaudio --start # 启动pulseaudio服务
安装 bluz 后就应该会自动创建 lp 用户组了,因此无需自己再创建新组
usermod -a -G lp $USER
默认情况下,蓝牙仅为 lp 用户组中的用户启用 bnep0 设备。如果想要加入蓝牙系统,需确认已将用户加入该组。可以修改 /etc/dbus-1/system.d/bluetooth.conf 文件中相应的组配置来实现。
启动 bluetoothctl 交互命令.可以输入 help 列出所有有效的命令。
以下为一个交互实例:
# bluetoothctl
[NEW] Controller 00:10:20:30:40:50 pi [default]
[bluetooth]# agent KeyboardOnly
Agent registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# scan on
Discovery started
[CHG] Controller 00:10:20:30:40:50 Discovering: yes
[NEW] Device 00:12:34:56:78:90 myLino
[CHG] Device 00:12:34:56:78:90 LegacyPairing: yes
[bluetooth]# pair 00:12:34:56:78:90
Attempting to pair with 00:12:34:56:78:90
[CHG] Device 00:12:34:56:78:90 Connected: yes
[CHG] Device 00:12:34:56:78:90 Connected: no
[CHG] Device 00:12:34:56:78:90 Connected: yes
Request PIN code
[agent] Enter PIN code: 1234
[CHG] Device 00:12:34:56:78:90 Paired: yes
Pairing successful
[CHG] Device 00:12:34:56:78:90 Connected: no
[bluetooth]# connect 00:12:34:56:78:90
Attempting to connect to 00:12:34:56:78:90
[CHG] Device 00:12:34:56:78:90 Connected: yes
Connection successful
将 /etc/bluetooth/main.conf 最后的 AutoEnable 值修改为 true
ansible localhost -m lineinfile -a "path=/etc/bluetooth/main.conf line='AutoEnable=true'"
通过 pavucontrol 的 Playback 和 Pecording 标签页重定向音频的输入和输出

