在登录屏幕上打开蓝牙

在登录屏幕上打开蓝牙

是否可以在登录屏幕时打开蓝牙并使用蓝牙键盘?到目前为止,我只能在登录时启动蓝牙守护进程。我将其添加到 systemd 中systemctl enable bluetooth,因此当我在我的用户中时它会启动,尽管它默认情况下处于关闭状态,我也想修复它。

我安装了bluezbluez-utils提供了该bluetoothhctl实用程序。如果这很重要的话,我也将其用作blueman前端。

答案1

默认情况下,蓝牙适配器重启后不会开机。

所以,如果你想开机后自动开机您需要AutoEnable=true在配置文件的/etc/bluetooth/main.conf底部添加以下行[Policy]

/etc/bluetooth/main.conf
------------------------------------------------------------------------------
[Policy]
AutoEnable=true

注意:不推荐使用前一种使用 hciconfig hci0 up 的方法。

来源:拱门维基

答案2

就像大多数时候我没有足够仔细地阅读 Arch Wiki 一样。有一节介绍如何在启动后激活设备。

您需要设置 udev 规则并使用/etc/udev/rules.d/10-local.rules以下代码创建

# Set bluetooth power up
ACTION=="add", KERNEL=="hci0", RUN+="/usr/bin/hciconfig hci0 up"

就是这样...它现在应该可以工作,即使 X 没有运行。

答案3

该解决方案在 OpenSUSE Tumbleweed 上对我有用systemd

  1. bluetooth.service被 要求multi-user.target。我使用了一个systemd嵌入式目录来实现它:
mkdir /etc/systemd/system/bluetooth.service.d
cat > /etc/systemd/system/bluetooth.service.d/multi-user.conf << EOF
[Install]
WantedBy=bluetooth.target multi-user.target
EOF
systemctl enable bluetooth.service
  1. 安装bluez-auto-enable-devices包以生成所需的AutoEnable=true配置/etc/bluetooth/main.conf
zypper in -y bluez-auto-enable-devices

重新启动后,我的蓝牙键盘和鼠标也可以在登录屏幕上使用。无需打开笔记本电脑盖子并使用笔记本电脑键盘进行登录。

答案4

在最新的内核中我必须使用:

# Set bluetooth power up
ACTION=="add", KERNEL=="hci0", RUN+="/bin/bluetoothctl --agent menu power on"

相关内容