我在使用内核 5.15.28-1 的 Manjaro
我的问题与蓝牙有关。我有 bluez 5.61-1(我从 5.63-2 降级)。
我可以使用 systemctl 激活蓝牙,但不能从我编写的 systemd 服务激活:
#/etc/systemd/system/bt-restart.service
[Unit]
Description=restart bt and connect keypad
[Service]
Type=oneshot
User=root
RemainAfterExit=yes
ExecStart=/usr/bin/sleep 1
ExecStart=-/usr/lib/systemd/system/bluetooth
ExecStart=/usr/bin/sleep 3
ExecStart=/home/jcw/bin/enable-bt.sh
[Install]
WantedBy=multi-user.target
输出自
sudo systemctl status bt-restart
● bt-restart.service - restart bt and connect keypad
Loaded: loaded (/etc/systemd/system/bt-restart.service; enabled; vendor preset: disabled)
Active: active (exited) since Sat 2022-03-19 09:00:35 CET; 1h 27min ago
Process: 2762 ExecStart=/usr/bin/sleep 1 (code=exited, status=0/SUCCESS)
Process: 2763 ExecStart=/usr/lib/systemd/system/bluetooth (code=exited, status=0/SUCCESS)
Process: 2764 ExecStart=/usr/bin/sleep 3 (code=exited, status=0/SUCCESS)
Process: 2766 ExecStart=/home/jcw/bin/enable-bt.sh (code=exited, status=0/SUCCESS)
Main PID: 2766 (code=exited, status=0/SUCCESS)
CPU: 41ms
mars 19 08:59:50 jcw-k30amjafk31amj systemd[1]: Starting restart bt and connect keypad...
mars 19 08:59:51 jcw-k30amjafk31amj systemd[2763]: bt-restart.service: Executable /usr/lib/systemd/system/bluetooth missing,>
mars 19 09:00:35 jcw-k30amjafk31amj enable-bt.sh[2767]: Attempting to connect to 2B:24:13:DB:7C:99
mars 19 09:00:35 jcw-k30amjafk31amj enable-bt.sh[2767]: Failed to connect: org.bluez.Error.Failed
mars 19 09:00:35 jcw-k30amjafk31amj systemd[1]: Finished restart bt and connect keypad.
从Executable /usr/lib/systemd/system/bluetooth missing可以看出,systemd 没有找到 bluetooth.service。
但该文件存在。可以通过 systemctl 访问。所以呢?
编辑:第二行的结尾是“缺少可执行文件/usr/lib/systemd/system/bluetooth,跳过:没有这样的文件或目录”