我正在尝试制定一条 udev 规则,该规则将在连接充电器时播放声音。该规则似乎运行良好,但我无法运行 shell 脚本。这是我的 udev 规则:
$cat 01-mru-battery-oncharger.rules
# Rule to play sound when charger
(AC0) is plugged in
SUBSYSTEM=="power_supply",
ENV{POWER_SUPPLY_NAME}=="AC0",
ENV{POWER_SUPPLY_ONLINE}=="1",
RUN+="/usr/local/bin/play_sound_charger_connected.sh"
这是脚本。/usr/local/bin 有一个指向我主目录中原始脚本的符号链接 (~/.customization/shell-scripts)
$cat .customization/shell-
scripts/play_sound_charger_connected.sh
#!/usr/bin/bash
/usr/bin/ffplay /home/xt/Music/System/Nothing\ Charging\ Sound.mp3 -nodisp -nostats -autoexit -hide_banner
当我运行 udev 测试时,它似乎触发了规则,但脚本不起作用——
AC0: /etc/udev/rules.d/01-mru-battery-oncharger.rules:3 RUN '/usr/bin/bash /usr/local/bin/play_sound_charger_connected.sh'
DEVPATH=/devices/pci0000:00/ACPI0003:00/power_supply/AC0
POWER_SUPPLY_NAME=AC0
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=1
ACTION=add
SUBSYSTEM=power_supply
USEC_INITIALIZED=827516597
run: '/usr/bin/bash /usr/local/bin/play_sound_charger_connected.sh'
我非常感谢任何建议。谢谢!!!