我在一台 2011 年中期的 iMac 上安装了 Ubuntu 17.10。在一台 Dell XPS 15 笔记本电脑上,我能够设置我的 Yubikey(通过 udev 规则),以便在 Yubikey 拔出或插入时激活和停用屏幕保护程序。我曾尝试在 Ubuntu 17.10 中设置同样的功能,但似乎没有任何效果。我已在规则的 RUN 部分中设置为 RUN 参数的脚本从未被触发。
/var/log/syslog
这是我插入 Yubikey 时的输出:
Dec 5 10:38:02 computer kernel: [ 814.455304] usb 2-1.3.1: new full-speed USB device number 10 using ehci-pci
Dec 5 10:38:02 computer kernel: [ 814.566229] usb 2-1.3.1: New USB device found, idVendor=1050, idProduct=0116
Dec 5 10:38:02 computer kernel: [ 814.566233] usb 2-1.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Dec 5 10:38:02 computer kernel: [ 814.566235] usb 2-1.3.1: Product: Yubikey NEO OTP+U2F+CCID
Dec 5 10:38:02 computer kernel: [ 814.566237] usb 2-1.3.1: Manufacturer: Yubico
Dec 5 10:38:02 computer kernel: [ 814.567661] input: Yubico Yubikey NEO OTP+U2F+CCID as /devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1/2-1.3.1:1.0/0003:1050:0116.000F/input/input21
Dec 5 10:38:02 computer kernel: [ 814.627832] hid-generic 0003:1050:0116.000F: input,hidraw5: USB HID v1.10 Keyboard [Yubico Yubikey NEO OTP+U2F+CCID] on usb-0000:00:1d.7-1.3.1/input0
Dec 5 10:38:02 computer kernel: [ 814.628715] hid-generic 0003:1050:0116.0010: hiddev2,hidraw6: USB HID v1.10 Device [Yubico Yubikey NEO OTP+U2F+CCID] on usb-0000:00:1d.7-1.3.1/input1
Dec 5 10:38:02 computer mtp-probe: checking bus 2, device 10: "/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1"
Dec 5 10:38:02 computer mtp-probe: bus: 2, device: 10 was not an MTP device
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (II) config/udev: Adding input device Yubico Yubikey NEO OTP+U2F+CCID (/dev/input/event9)
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (**) Yubico Yubikey NEO OTP+U2F+CCID: Applying InputClass "libinput keyboard catchall"
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (II) Using input driver 'libinput' for 'Yubico Yubikey NEO OTP+U2F+CCID'
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[2389]: (II) config/udev: Adding input device Yubico Yubikey NEO OTP+U2F+CCID (/dev/input/event9)
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[2389]: (**) Yubico Yubikey NEO OTP+U2F+CCID: Applying InputClass "libinput keyboard catchall"
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[2389]: (II) Using input driver 'libinput' for 'Yubico Yubikey NEO OTP+U2F+CCID'
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (II) systemd-logind: got fd for /dev/input/event9 13:73 fd 56 paused 0
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (**) Yubico Yubikey NEO OTP+U2F+CCID: always reports core events
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (**) Option "Device" "/dev/input/event9"
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (**) Option "_source" "server/udev"
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (II) event9 - (II) Yubico Yubikey NEO OTP+U2F+CCID: (II) is tagged by udev as: Keyboard
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (II) event9 - (II) Yubico Yubikey NEO OTP+U2F+CCID: (II) device is a keyboard
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (II) event9 - (II) Yubico Yubikey NEO OTP+U2F+CCID: (II) device removed
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (**) Option "config_info" "udev:/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1/2-1.3.1:1.0/0003:1050:0116.000F/input/input21/event9"
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (II) XINPUT: Adding extended input device "Yubico Yubikey NEO OTP+U2F+CCID" (type: KEYBOARD, id 15)
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (**) Option "xkb_model" "pc105"
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (**) Option "xkb_layout" "us"
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (WW) Option "xkb_variant" requires a string value
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (WW) Option "xkb_options" requires a string value
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (II) event9 - (II) Yubico Yubikey NEO OTP+U2F+CCID: (II) is tagged by udev as: Keyboard
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[4002]: (II) event9 - (II) Yubico Yubikey NEO OTP+U2F+CCID: (II) device is a keyboard
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[2389]: (II) systemd-logind: got fd for /dev/input/event9 13:73 fd 30 paused 1
Dec 5 10:38:02 computer /usr/lib/gdm3/gdm-x-session[2389]: (II) systemd-logind: releasing fd for 13:73
当我使用时udevadm info
,我得到的结果如下:
looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1':
KERNELS=="2-1.3.1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="30mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 3"
ATTRS{bcdDevice}=="0333"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="2"
ATTRS{configuration}==""
ATTRS{devnum}=="7"
ATTRS{devpath}=="1.3.1"
ATTRS{idProduct}=="0116"
ATTRS{idVendor}=="1050"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Yubico"
ATTRS{maxchild}=="0"
ATTRS{product}=="Yubikey NEO OTP+U2F+CCID"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="removable"
ATTRS{speed}=="12"
ATTRS{urbnum}=="262"
ATTRS{version}==" 2.00"
并udevadm test
输出以下内容:
calling: test
version 234
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
=== trie on-disk ===
tool version: 234
file size: 9138024 bytes
header size 80 bytes
strings 1910832 bytes
nodes 7227112 bytes
Load module index
Found container virtualization none.
timestamp of '/etc/systemd/network' changed
timestamp of '/lib/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Reading rules file: /lib/udev/rules.d/39-usbmuxd.rules
Reading rules file: /lib/udev/rules.d/40-usb-media-players.rules
Reading rules file: /lib/udev/rules.d/40-usb_modeswitch.rules
Reading rules file: /lib/udev/rules.d/40-vm-hotadd.rules
Reading rules file: /lib/udev/rules.d/50-apport.rules
Reading rules file: /lib/udev/rules.d/50-firmware.rules
Reading rules file: /lib/udev/rules.d/50-udev-default.rules
Reading rules file: /lib/udev/rules.d/55-dm.rules
Reading rules file: /lib/udev/rules.d/55-ippusbxd.rules
Reading rules file: /lib/udev/rules.d/56-hpmud.rules
Reading rules file: /lib/udev/rules.d/60-block.rules
Reading rules file: /lib/udev/rules.d/60-cdrom_id.rules
Reading rules file: /lib/udev/rules.d/60-crda.rules
Reading rules file: /lib/udev/rules.d/60-drm.rules
Reading rules file: /lib/udev/rules.d/60-evdev.rules
Reading rules file: /lib/udev/rules.d/60-gnupg2.rules
Reading rules file: /lib/udev/rules.d/60-input-id.rules
Reading rules file: /lib/udev/rules.d/60-inputattach.rules
Reading rules file: /lib/udev/rules.d/60-libgphoto2-6.rules
Reading rules file: /lib/udev/rules.d/60-libsane1.rules
Reading rules file: /lib/udev/rules.d/60-pcmcia.rules
Reading rules file: /lib/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /lib/udev/rules.d/60-persistent-input.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /lib/udev/rules.d/60-persistent-storage.rules
Reading rules file: /lib/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /lib/udev/rules.d/60-scdaemon.rules
Reading rules file: /lib/udev/rules.d/60-sensor.rules
Reading rules file: /lib/udev/rules.d/60-serial.rules
Reading rules file: /lib/udev/rules.d/61-gnome-settings-daemon-rfkill.rules
Reading rules file: /lib/udev/rules.d/61-persistent-storage-android.rules
Reading rules file: /lib/udev/rules.d/64-btrfs.rules
Reading rules file: /lib/udev/rules.d/64-xorg-xkb.rules
Reading rules file: /lib/udev/rules.d/65-libwacom.rules
Reading rules file: /lib/udev/rules.d/66-snapd-autoimport.rules
Reading rules file: /lib/udev/rules.d/66-xorg-synaptics-quirks.rules
Reading rules file: /lib/udev/rules.d/69-cd-sensors.rules
Reading rules file: /lib/udev/rules.d/69-libmtp.rules
Reading rules file: /lib/udev/rules.d/69-wacom.rules
Reading rules file: /lib/udev/rules.d/69-yubikey.rules
Reading rules file: /lib/udev/rules.d/70-debian-uaccess.rules
Reading rules file: /lib/udev/rules.d/70-mouse.rules
Reading rules file: /lib/udev/rules.d/70-old-u2f.rules
Reading rules file: /lib/udev/rules.d/70-power-switch.rules
Reading rules file: /lib/udev/rules.d/70-printers.rules
Reading rules file: /lib/udev/rules.d/70-touchpad.rules
Reading rules file: /etc/udev/rules.d/70-u2f.rules
Reading rules file: /lib/udev/rules.d/70-uaccess.rules
Reading rules file: /lib/udev/rules.d/71-power-switch-proliant.rules
Reading rules file: /lib/udev/rules.d/71-seat.rules
Reading rules file: /lib/udev/rules.d/71-u-d-c-gpu-detection.rules
Reading rules file: /lib/udev/rules.d/73-seat-late.rules
Reading rules file: /lib/udev/rules.d/73-special-net-names.rules
Reading rules file: /lib/udev/rules.d/73-usb-net-by-mac.rules
Reading rules file: /lib/udev/rules.d/75-net-description.rules
Reading rules file: /lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /lib/udev/rules.d/77-mm-cinterion-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-dell-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-ericsson-mbm.rules
Reading rules file: /lib/udev/rules.d/77-mm-haier-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-huawei-net-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-longcheer-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-mtk-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-nokia-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-pcmcia-device-blacklist.rules
Reading rules file: /lib/udev/rules.d/77-mm-platform-serial-whitelist.rules
Reading rules file: /lib/udev/rules.d/77-mm-qdl-device-blacklist.rules
Reading rules file: /lib/udev/rules.d/77-mm-simtech-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-telit-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-usb-device-blacklist.rules
Reading rules file: /lib/udev/rules.d/77-mm-usb-serial-adapters-greylist.rules
Reading rules file: /lib/udev/rules.d/77-mm-x22x-port-types.rules
Reading rules file: /lib/udev/rules.d/77-mm-zte-port-types.rules
Reading rules file: /lib/udev/rules.d/78-graphics-card.rules
Reading rules file: /lib/udev/rules.d/78-sound-card.rules
Reading rules file: /lib/udev/rules.d/80-debian-compat.rules
Reading rules file: /lib/udev/rules.d/80-docker-ce.rules
Reading rules file: /lib/udev/rules.d/80-drivers.rules
Reading rules file: /lib/udev/rules.d/80-ifupdown.rules
Reading rules file: /lib/udev/rules.d/80-iio-sensor-proxy.rules
Reading rules file: /lib/udev/rules.d/80-libinput-device-groups.rules
Reading rules file: /lib/udev/rules.d/80-mm-candidate.rules
Reading rules file: /lib/udev/rules.d/80-net-setup-link.rules
Reading rules file: /lib/udev/rules.d/80-snappy-assign.rules
Reading rules file: /lib/udev/rules.d/80-udisks2.rules
Reading rules file: /lib/udev/rules.d/84-nm-drivers.rules
Reading rules file: /lib/udev/rules.d/85-brltty.rules
Reading rules file: /lib/udev/rules.d/85-hdparm.rules
Reading rules file: /lib/udev/rules.d/85-hplj10xx.rules
Reading rules file: /lib/udev/rules.d/85-nm-unmanaged.rules
Reading rules file: /lib/udev/rules.d/85-regulatory.rules
Reading rules file: /lib/udev/rules.d/90-alsa-restore.rules
Reading rules file: /lib/udev/rules.d/90-console-setup.rules
Reading rules file: /lib/udev/rules.d/90-fwupd-devices.rules
Reading rules file: /lib/udev/rules.d/90-libgpod.rules
Reading rules file: /lib/udev/rules.d/90-libinput-model-quirks.rules
Reading rules file: /lib/udev/rules.d/90-pulseaudio.rules
Reading rules file: /lib/udev/rules.d/92-libccid.rules
Reading rules file: /lib/udev/rules.d/95-cd-devices.rules
Reading rules file: /lib/udev/rules.d/95-upower-csr.rules
Reading rules file: /lib/udev/rules.d/95-upower-hid.rules
Reading rules file: /lib/udev/rules.d/95-upower-wup.rules
Reading rules file: /lib/udev/rules.d/97-hid2hci.rules
Reading rules file: /lib/udev/rules.d/99-systemd.rules
rules contain 393216 bytes tokens (32768 * 12 bytes), 36008 bytes strings
24465 strings (207924 bytes), 21215 de-duplicated (175167 bytes), 3251 trie nodes used
value '[dmi/id]sys_vendor' is 'Apple Inc.'
value '[dmi/id]sys_vendor' is 'Apple Inc.'
GROUP 106 /lib/udev/rules.d/50-udev-default.rules:29
IMPORT builtin 'hwdb' /lib/udev/rules.d/60-evdev.rules:8
RUN 'keyboard' /lib/udev/rules.d/60-evdev.rules:8
IMPORT builtin 'input_id' /lib/udev/rules.d/60-input-id.rules:5
capabilities/ev raw kernel attribute: 120013
capabilities/abs raw kernel attribute: 0
capabilities/rel raw kernel attribute: 0
capabilities/key raw kernel attribute: e080ffdf01cfffff fffffffffffffffe
properties raw kernel attribute: 0 test_key: checking bit block 0 for any keys; found=1
test_key: checking bit block 64 for any keys; found=1
test_key: checking bit block 128 for any keys; found=1
test_key: checking bit block 192 for any keys; found=1
IMPORT builtin 'usb_id' /lib/udev/rules.d/60-persistent-input.rules:11
/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1/2-1.3.1:1. if_class 3 protocol 0
LINK 'input/by-id/usb-Yubico_Yubikey_NEO_OTP+U2F+CCID-event-kbd' /lib/udev/rules.d/60-persistent-input.rules:28
IMPORT builtin 'path_id' /lib/udev/rules.d/60-persistent-input.rules:35
LINK 'input/by-path/pci-0000:00:1d.7-usb-0:1.3.1:1.0-event-kbd' /lib/udev/rules.d/60-persistent-input.rules:37
RUN 'uaccess' /lib/udev/rules.d/73-seat-late.rules:15
PROGRAM 'libinput-device-group /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1/2-1.3.1:1.0/0003:1050:0116.0011/input/input22/event9' /lib/udev/rules.d/80-libinput-device-groups.rules:7
starting 'libinput-device-group /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1/2-1.3.1:1.0/0003:1050:0116.0011/input/input22/event9'
'libinput-device-group /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1/2-1.3.1:1.0/0003:1050:0116.0011/input/input22/event9'(out) '3/1050/116/110:usb-0000:00:1d.7-1.3'
Process 'libinput-device-group /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1/2-1.3.1:1.0/0003:1050:0116.0011/input/input22/event9' succeeded.
IMPORT builtin 'hwdb' /lib/udev/rules.d/90-libinput-model-quirks.rules:38
IMPORT builtin 'hwdb' returned non-zero
value '[dmi/id]modalias' is 'dmi:bvnAppleInc.:bvrIM121.88Z.0047.B1E.1110201314:bd10/20/11:svnAppleInc.:pniMac12,2:pvr1.0:rvnAppleInc.:rnMac-942B59F58194171B:rvriMac12,2:cvnAppleInc.:ct13:cvrMac-942B59F58194171B:'
IMPORT builtin 'hwdb' /lib/udev/rules.d/90-libinput-model-quirks.rules:42
IMPORT builtin 'hwdb' returned non-zero
IMPORT builtin 'hwdb' /lib/udev/rules.d/90-libinput-model-quirks.rules:46
IMPORT builtin 'hwdb' returned non-zero
handling device node '/dev/input/event9', devnum=c13:73, mode=0660, uid=0,gid=106
preserve permissions /dev/input/event9, 020660, uid=0, gid=106
preserve already existing symlink '/dev/char/13:73' to '../input/event9'
found 'c13:73' claiming '/run/udev/links/\x2finput\x2fby-id\x2fusb-Yubico_Yubikey_NEO_OTP+U2F+CCID-event-kbd'
creating link '/dev/input/by-id/usb-Yubico_Yubikey_NEO_OTP+U2F+CCID-event-kbd' to '/dev/input/event9'
preserve already existing symlink '/dev/input/by-id/usb-Yubico_Yubikey_NEO_OTP+U2F+CCID-event-kbd' to '../event9'
found 'c13:73' claiming '/run/udev/links/\x2finput\x2fby-path\x2fpci-0000:00:1d.7-usb-0:1.3.1:1.0-event-kbd'
creating link '/dev/input/by-path/pci-0000:00:1d.7-usb-0:1.3.1:1.0-event-kbd' to
'/dev/input/event9'
preserve already existing symlink '/dev/input/by-path/pci-0000:00:1d.7-usb-0:1.3.1:1.0-event-kbd' to '../event9'
created db file '/run/udev/data/c13:73' for '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1/2-1.3.1:1.0/0003:1050:0116.0011/input/input22/event9'
.INPUT_CLASS=kbd
.MM_USBIFNUM=00
ACTION=add
BACKSPACE=guess
DEVLINKS=/dev/input/by-id/usb-Yubico_Yubikey_NEO_OTP+U2F+CCID-event-kbd /dev/input/by-path/pci-0000:00:1d.7-usb-0:1.3.1:1.0-event-kbd
DEVNAME=/dev/input/event9
DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1.3/2-1.3.1/2-1.3.1:1.0/0003:1050:0116.0011/input/input22/event9
ID_BUS=usb
ID_FOR_SEAT=input-pci-0000_00_1d_7-usb-0_1_3_1_1_0
ID_INPUT=1
ID_INPUT_KEY=1
ID_INPUT_KEYBOARD=1
ID_MODEL=Yubikey_NEO_OTP+U2F+CCID
ID_MODEL_ENC=Yubikey\x20NEO\x20OTP+U2F+CCID
ID_MODEL_ID=0116
ID_PATH=pci-0000:00:1d.7-usb-0:1.3.1:1.0
ID_PATH_TAG=pci-0000_00_1d_7-usb-0_1_3_1_1_0
ID_REVISION=0333
ID_SECURITY_TOKEN=1
ID_SERIAL=Yubico_Yubikey_NEO_OTP+U2F+CCID
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030101:030000:0b0000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Yubico
ID_VENDOR_ENC=Yubico
ID_VENDOR_ID=1050
LIBINPUT_DEVICE_GROUP=3/1050/116/110:usb-0000:00:1d.7-1.3
MAJOR=13
MINOR=73
SUBSYSTEM=input
TAGS=:seat:power-switch:uaccess:
USEC_INITIALIZED=1090409060
XKBLAYOUT=us
XKBMODEL=pc105
XKBOPTIONS=
XKBVARIANT=
XKB_FIXED_LAYOUT="us"
XKB_FIXED_VARIANT=""
run: 'keyboard'
run: 'uaccess'
Unload module index
Unloaded link configuration context.
最后,udev 规则应该触发的脚本:
#!/bin/bash
USERNAME="sean"
action=$1
logger "YubiKey Removed or Inserted, ${action}"
无论我在 udev 规则中使用KERNEL
、SUBSYSTEM
、ATTRS
或 的哪种组合ENV
,该脚本似乎都无法触发。我甚至只是输入只是 SYSTEM=="hidraw|usb|input"
重新加载规则后,没有任何内容显示syslog
。我尝试了/etc/init.d/udev restart
、udevadm control -R
和service udev reload
,但似乎没有任何内容能够触发规则/etc/udev/rules.d
。
据我所知,/etc/udev/rules.d/99-yubikey.rules
udev 没有加载或看到它(它没有出现在udevadm test
输出中)。
有什么我可以尝试来实现这个功能的想法吗?
答案1
您的udev
规则未包含在您的问题中,但来自本论坛我复制了一份并修改了一下:
$ cat /etc/udev/rules.d/45-yubikey.rules
ACTION=="add", ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0116", RUN+="/path/to/screensaver-unlock.sh"
ACTION=="remove", ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0116", RUN+="/path/to/screensaver-locksh"
笔记:产品 ID0010
已更改为0116
与您的信息相匹配udev
。
正如评论者指出的那样,论坛上用于锁定和解锁屏幕的脚本并不是非常安全。
看看今天的评论,它提醒我确保您的脚本被标记为可执行文件:
chmod a+x /path/to/script.sh
答案2
嗯,对我来说这显然是一个规则文件名问题。:P 拼写错误可能很容易隐藏在代码中。
未被 udev 加载。
Reading rules file: /lib/udev/rules.d/97-hid2hci.rules Reading rules file: /lib/udev/rules.d/99-systemd.rules rules contain 393216 bytes tokens (32768 * 12 bytes), 36008 bytes strings
检查这里的文件名(由 op 从评论中输出)
$ stat /etc/udev/rules.d/99-yubikey-rules File: /etc/udev/rules.d/99-yubikey-rules Size: 546 Blocks: 8 IO Block: 4096 regular file Device: 802h/2050d Inode: 14818409 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2017-12-18 10:49:08.526648161 -0800 Modify: 2017-12-18 10:49:08.546647827 -0800 Change: 2017-12-18 10:49:08.622646564 -0800 Birth: -
使固定:
Wrong 99-yubikey-rules
Correct 99-yubikey.rules