Blueman
Blueman 是一个功能完善的 Bluetooth 管理器,使用 Python 编写并使用 GTK。
安装
安装 blueman 或 blueman-gitAUR 以获取开发版本。
请务必启用 Bluetooth 单元并使用 blueman-applet
启动 Blueman。可以使用 blueman-manager
启动图形设置面板。
用法
自动启动
应该已创建以下自动启动文件:/etc/xdg/autostart/blueman.desktop
。这意味着 Blueman 应该在大多数桌面环境下自动启动,无需手动干预。有关自动启动的更多信息,请参阅您的桌面环境或窗口管理器的文档,以及 自动启动 文章。
权限
要接收文件,请记住右键单击Blueman 托盘图标 > 本地服务 > 传输 > 文件接收(对象推送),并勾选接受来自信任设备的文件框。
为了能够管理设备,您可能需要将您的用户添加到 lp
组,否则在连接到设备时可能会收到以下错误:DBusFailedError: No such file or directory
。这是因为用户需要被授权通过 D-Bus 与 Bluetooth 守护进程通信 - lp
组在 /etc/dbus-1/system.d/bluetooth.conf
中指定。有关将用户添加到组的信息,请参阅 用户和组#用户管理的其他示例。
从 2.0.6 版本开始,官方文档建议创建 polkit 规则,以避免 polkit 代理在每次启动时都要求输入密码,作为 root 用户添加以下 polkit 规则
/etc/polkit-1/rules.d/51-blueman.rules
/* Allow users in wheel group to use blueman feature requiring root without authentication */ polkit.addRule(function(action, subject) { if ((action.id == "org.blueman.network.setup" || action.id == "org.blueman.dhcp.client" || action.id == "org.blueman.rfkill.setstate" || action.id == "org.blueman.pppd.pppconnect") && subject.isInGroup("wheel")) { return polkit.Result.YES; } });
请注意,用户必须属于 wheel
组。
挂载蓝牙设备
以下说明描述了一种将不同文件管理器与 Blueman 一起使用的方法。本节中的示例侧重于 Thunar。如果您使用不同的文件管理器,请将 thunar 替换为您正在使用的文件管理器的名称。
obex_thunar.sh
#!/bin/bash [ ! -d ~/Bluetooth ] && mkdir ~/Bluetooth fusermount -u ~/Bluetooth obexfs -b $1 ~/Bluetooth thunar ~/Bluetooth
现在您需要将脚本移动到适当的位置(例如,/usr/local/bin
)。之后,将其标记为可执行。
最后一步是将Blueman 托盘图标 > 本地服务 > 传输 > 高级中的行更改为 obex_thunar.sh %d
。
Blueman 和 PulseAudio
想要将 PulseAudio 与蓝牙耳机一起使用的用户,除了安装 pulseaudio-bluetooth 之外,可能还希望激活 Blueman 的 PulseAudio 插件。这会在音频设备连接后自动加载 PulseAudio Bluetooth 模块,并通过蓝牙耳机播放所有音频。有关更多信息,请参阅 蓝牙耳机。
配置
配置通过 /org/blueman
下的 dconf(或 gsettings 或 dconf-editor)完成。
禁用自动开机
当某些事件(启动时、笔记本电脑盖子打开时等)发生时,Blueman 会自动启用 Bluetooth 适配器 (rfkill unblock bluetooth
)。可以使用 org.blueman.plugins.powermanager
中的 auto-power-on
禁用此功能
$ gsettings set org.blueman.plugins.powermanager auto-power-on false
通过通知守护程序接收通知
如果存在通知守护程序(例如 dunst),Blueman 可以通过它发送通知。在没有通知守护程序的情况下,blueman 使用基于窗口的后备方案。可以通过切换 org.blueman.general
中的 notification-daemon
设置来配置此行为
$ gsettings set org.blueman.general notification-daemon true
故障排除
未检测到适配器
如果您的 Bluetooth 小程序或管理器未显示或检测到任何 Bluetooth 适配器,则可能是您的无线网卡被阻止了。尝试使用 rfkill 取消阻止。
无法接收文件
如果您无法发送或接收文件,并且遇到类似于或完全像 process org.bluez.obex exited with status 1
的 python-dbus-exception 错误,建议从 /usr/lib/bluetooth/obexd
手动启动 obexd-service,看看是否有帮助。由于默认权限假定为 755,因此可以从用户帐户启动守护进程。
使用此行启动它
# /usr/lib/bluetooth/obexd -n
让运行命令的终端保持打开状态,并测试发送文件是否有效。检查您是否实际收到了文件。您可以将该命令添加到您的 自动启动器,这样您就不必每次都手动启动该服务。您的桌面环境自动启动器应该能够在您登录后运行该程序。注销并重新登录,您现在应该能够接收文件而无需手动运行该行命令。
如果错误仍然存在或发生其他错误,请尝试使用 ObexFTP 进行文件传输。
参见
- Blueman 开发,在 GitHub 上