다음 장치인 Sony Computer Entertainment Inc BD Remote Control에 대한 간단한 udev 규칙을 만들려고 하는데 작동하지 않습니다. 여러 튜토리얼, 일부 문서 및 이와 같은 의심스러운 게시물을 읽었습니다. 어쨌든 할 수 있습니다. 작동하지도 않습니다.
이것이 장치 속성 버그인지, udev 규칙을 지원하지 않는 배포판인지, 아니면 다른 버그인지 모르겠습니다.
"sudo restart"는 테스트 목적으로만 사용됩니다.
저는 리눅스 민트를 사용하고 있습니다.
Linux Mint Linux HP 4.15.0-20-generic #21-Ubuntu SMP 화요일 4월 24일 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
이것은 내가 수행한 여러 테스트 중 하나입니다.
ACTION=="add", SUBSYSTEM=="input", SUBSYSTEMS=="input",
ATTR{phys}=="00:19:86:00:15:36", RUN+="sudo reboot"
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/bluetooth/hci0/hci0:11/0005:054C:0306.003A/input/input70/event15':
KERNEL=="event15"
SUBSYSTEM=="input"
DRIVER==""
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/bluetooth/hci0/hci0:11/0005:054C:0306.003A/input/input70':
KERNELS=="input70"
SUBSYSTEMS=="input"
DRIVERS==""
ATTRS{name}=="Sony Computer Entertainment Inc BD Remote Control"
ATTRS{phys}=="00:19:86:00:15:36"
ATTRS{properties}=="0"
ATTRS{uniq}=="00:06:f5:97:ab:94"
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/bluetooth/hci0/hci0:11/0005:054C:0306.003A':
KERNELS=="0005:054C:0306.003A"
SUBSYSTEMS=="hid"
DRIVERS=="sony"
ATTRS{country}=="21"
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/bluetooth/hci0/hci0:11':
KERNELS=="hci0:11"
SUBSYSTEMS=="bluetooth"
DRIVERS==""
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0/bluetooth/hci0':
KERNELS=="hci0"
SUBSYSTEMS=="bluetooth"
DRIVERS==""
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1/2-1.1:1.0':
KERNELS=="2-1.1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="btusb"
ATTRS{authorized}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceProtocol}=="01"
ATTRS{bInterfaceSubClass}=="01"
ATTRS{bNumEndpoints}=="03"
ATTRS{supports_autosuspend}=="1"
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1':
KERNELS=="2-1.1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="ff"
ATTRS{bDeviceProtocol}=="01"
ATTRS{bDeviceSubClass}=="01"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="0mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 4"
ATTRS{bcdDevice}=="0112"
ATTRS{bmAttributes}=="e0"
ATTRS{busnum}=="2"
ATTRS{configuration}==""
ATTRS{devnum}=="22"
ATTRS{devpath}=="1.1"
ATTRS{idProduct}=="21e8"
ATTRS{idVendor}=="0a5c"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Broadcom Corp"
ATTRS{maxchild}=="0"
ATTRS{product}=="BCM20702A0"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="removable"
ATTRS{serial}=="001986001536"
ATTRS{speed}=="12"
ATTRS{urbnum}=="434"
ATTRS{version}==" 2.00"
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2/2-1':
KERNELS=="2-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="09"
ATTRS{bDeviceProtocol}=="01"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="0mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0000"
ATTRS{bmAttributes}=="e0"
ATTRS{busnum}=="2"
ATTRS{configuration}==""
ATTRS{devnum}=="2"
ATTRS{devpath}=="1"
ATTRS{idProduct}=="0024"
ATTRS{idVendor}=="8087"
ATTRS{ltm_capable}=="no"
ATTRS{maxchild}=="6"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="fixed"
ATTRS{speed}=="480"
ATTRS{urbnum}=="497"
ATTRS{version}==" 2.00"
looking at parent device '/devices/pci0000:00/0000:00:1d.0/usb2':
KERNELS=="usb2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{authorized_default}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="09"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="0mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0415"
ATTRS{bmAttributes}=="e0"
ATTRS{busnum}=="2"
ATTRS{configuration}==""
ATTRS{devnum}=="1"
ATTRS{devpath}=="0"
ATTRS{idProduct}=="0002"
ATTRS{idVendor}=="1d6b"
ATTRS{interface_authorized_default}=="1"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Linux 4.15.0-20-generic ehci_hcd"
ATTRS{maxchild}=="2"
ATTRS{product}=="EHCI Host Controller"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="unknown"
ATTRS{serial}=="0000:00:1d.0"
ATTRS{speed}=="480"
ATTRS{urbnum}=="187"
ATTRS{version}==" 2.00"
looking at parent device '/devices/pci0000:00/0000:00:1d.0':
KERNELS=="0000:00:1d.0"
SUBSYSTEMS=="pci"
DRIVERS=="ehci-pci"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x0c0320"
ATTRS{companion}==""
ATTRS{consistent_dma_mask_bits}=="32"
ATTRS{d3cold_allowed}=="1"
ATTRS{device}=="0x1e26"
ATTRS{dma_mask_bits}=="32"
ATTRS{driver_override}=="(null)"
ATTRS{enable}=="1"
ATTRS{irq}=="23"
ATTRS{local_cpulist}=="0-3"
ATTRS{local_cpus}=="0f"
ATTRS{msi_bus}=="1"
ATTRS{numa_node}=="-1"
ATTRS{revision}=="0x04"
ATTRS{subsystem_device}=="0x1854"
ATTRS{subsystem_vendor}=="0x103c"
ATTRS{uframe_periodic_max}=="100"
ATTRS{vendor}=="0x8086"
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
업데이트: 이 명령을 사용하면 sudo systemctl status udev.service
규칙이 작동하는 것처럼 보이지만 스크립트( .sh
) 또는 프로그램( /usr/bin/qbittorrent
)이 실행되지 않고 이 오류가 발생합니다.
● systemd-udevd.service - udev Kernel Device Manager
Loaded: loaded (/etc/systemd/system/systemd-udevd.service; static; vendor preset: enabled)
Active: active (running) since Wed 2019-03-06 12:21:22 -03; 8min ago
Docs: man:systemd-udevd.service(8)
man:udev(7)
Main PID: 399 (systemd-udevd)
Status: "Processing with 16 children at max"
Tasks: 1
CGroup: /system.slice/systemd-udevd.service
└─399 /lib/systemd/systemd-udevd
mar 06 12:21:25 HP systemd-udevd[1939]: Process '/home/luiz/loop.sh' failed with exit code 1.
mar 06 12:21:26 HP systemd-udevd[2196]: Process '/home/luiz/loop.sh' failed with exit code 1.
mar 06 12:21:26 HP systemd-udevd[2220]: Process '/home/luiz/loop.sh' failed with exit code 1.
mar 06 12:21:31 HP systemd-udevd[2504]: Process '/home/luiz/loop.sh' failed with exit code 1.
mar 06 12:25:42 HP systemd-udevd[3225]: Process '/home/luiz/loop.sh' failed with exit code 1.
답변1
내가 찾은 해결책은 /lib/udev/rules.d
다음 형식으로 udev 규칙을 만드는 것이었습니다.
ACTION=="add", \
SUBSYSTEM=="input", \
ATTR{uniq}=="00:06:f5:97:ab:94" \
RUN+="/bin/systemctl start --no-block ps3bdremote.service
스크립트를 실행하는 대신 명령을 사용하여 서비스, /bin/systemctl start --no-block
즉 서비스를 실행했는데, 올바르게 기억한다면 이 솔루션은 장기 실행 스크립트를 실행할 때 시간 초과 문제를 해결할 것이지만 테스트하지는 않았습니다.
다음과 같은 서비스가 있습니다 /etc/systemd/system/ps3bdremote.service
.
[Unit]
Description=PS3 BD Remote Script.
[Service]
Type=simple
User=luiz
Environment=XAUTHORITY=/home/luiz/.Xauthority
Environment=DISPLAY=:0
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
ExecStart=/usr/bin/python3 /media/luiz/HD/posinstall/repos/ps3bdremote/ps3bdremote.py -s
[Install]
WantedBy=graphical.target
이 부분은 선택 사항이라고 생각합니다. 누군가 비슷한 것을 시도하면 데스크탑 알림 생성(KDE 사용)을 허용하기 때문에 사용하지만 다른 인터페이스에서도 동일해야 합니다.
Environment=XAUTHORITY=/home/luiz/.Xauthority
Environment=DISPLAY=:0
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus