마우스 두 개가 있는데 하나는 가운데 마우스 버튼과 button6이 동시에 트리거되는 문제가 있습니다. 그래서이 ~/.Xmodmap
버튼을 비활성화 하도록 구성했습니다 . 그러나 동시에이 버튼을 다른 마우스와 함께 사용할 수 있기를 원했습니다. 그래서 어떤 마우스가 연결되어 있는지에 따라 버튼 레이아웃을 변경하기 위해 udev
호출 되는 규칙을 작성했습니다 xmodmap
.
설정
이것은 내 현재 설정입니다.
/etc/udev/rules.d/logitech-g7.rules :
# deactivate MB 6 when mouse 1 is connected
ACTION=="add", ENV{DEVTYPE}=="usb_device", ENV{ID_VENDOR_ID}=="046d", ENV{ID_MODEL_ID}=="c51a", RUN+="/home/user/.scripts/Troubleshooting/Bugfixes/mouseswitcher_wrapper 1", OWNER="user"
# restore defaults when mouse 1 is disconnected
ACTION=="remove", ENV{DEVTYPE}=="usb_device", ENV{ID_VENDOR_ID}=="046d", ENV{ID_MODEL_ID}=="c51a", RUN+="/home/user/.scripts/Troubleshooting/Bugfixes/mouseswitcher_wrapper 0", OWNER="user"
/home/user/.scripts/ 문제 해결 / 버그 수정 / mouseswitcher_wrapper :
#!/bin/bash
/home/user/.scripts/Troubleshooting/Bugfixes/mouseswitcher "$1"&
/home/user/.scripts/ 문제 해결 / 버그 수정 / 마우스 스위처
#!/bin/bash
sleep 1
DISPLAY=":0.0"
HOME=/home/user/
XAUTHORITY=$HOME/.Xauthority
export DISPLAY XAUTHORITY HOME
if [[ "$1" == 1 ]] #differentiate between ADD (1) event and REMOVE (0) event
then
/usr/bin/xmodmap /home/user/.XmodmapG7 > /dev/null 2>&1
else
/usr/bin/xmodmap /home/user/.Xmodmap > /dev/null 2>&1
fi
이 솔기가 약간 복잡해지면 udev, xmodmap 및 DISPLAY 변수와 같은 많은 문제가 발생했기 때문입니다. 내 스크립트는 이 Q & A를 기반으로 합니다 .
현재 상태
ADD 작업은 제대로 작동하지만 REMOVE 작업은 작동하지 않습니다. 터미널에서 RUN 명령 중 하나를 수동으로 실행하면 정상적으로 작동합니다.
내가 지금까지 시도한 것
나는 발견 이 포럼 게시물 udev에가 제거 작업에 문제가 따라 ENV 변수로 바인드합니다 대체 왜 윤곽을. 그러나이 모든 것이 소용이 없었습니다. 제거 트리거는 여전히 작동하지 않습니다.
내가 잘못하고있는 것이 있어야합니다. udev와 Linux에 대해 더 정통한 누군가가 내 사건을 살펴볼 수 있다면 정말 감사하겠습니다.
추가 정보
udevadm monitor --environment --udev
수신기를 꽂을 때의 출력 :
######ADD#######
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
UDEV [21728.392805] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3 (usb)
ACTION=add
BUSNUM=002
DEVNAME=/dev/bus/usb/002/037
DEVNUM=037
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c51a
ID_REVISION=4100
ID_SERIAL=Logitech_USB_Receiver
ID_USB_INTERFACES=:030102:030000:
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
MAJOR=189
MINOR=164
PRODUCT=46d/c51a/4100
SEQNUM=3139
SUBSYSTEM=usb
TYPE=0/0/0
UDEV_LOG=3
UPOWER_VENDOR=Logitech, Inc.
USEC_INITIALIZED=21727880859
UDEV [21728.393864] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0
DEVTYPE=usb_interface
INTERFACE=3/1/2
MODALIAS=usb:v046DpC51Ad4100dc00dsc00dp00ic03isc01ip02in00
PRODUCT=46d/c51a/4100
SEQNUM=3140
SUBSYSTEM=usb
TYPE=0/0/0
UDEV_LOG=3
USEC_INITIALIZED=21728393779
UDEV [21728.395536] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1 (usb)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1
DEVTYPE=usb_interface
INTERFACE=3/0/0
MODALIAS=usb:v046DpC51Ad4100dc00dsc00dp00ic03isc00ip00in01
PRODUCT=46d/c51a/4100
SEQNUM=3146
SUBSYSTEM=usb
TYPE=0/0/0
UDEV_LOG=3
USEC_INITIALIZED=21728395426
UDEV [21728.395737] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C51A.004B (hid)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C51A.004B
HID_ID=0003:0000046D:0000C51A
HID_NAME=Logitech USB Receiver
HID_PHYS=usb-0000:00:1d.0-1.3/input0
MODALIAS=hid:b0003g0001v0000046Dp0000C51A
SEQNUM=3141
SUBSYSTEM=hid
UDEV_LOG=3
USEC_INITIALIZED=21728395467
UDEV [21728.398102] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:046D:C51A.004C (hid)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:046D:C51A.004C
HID_ID=0003:0000046D:0000C51A
HID_NAME=Logitech USB Receiver
HID_PHYS=usb-0000:00:1d.0-1.3/input1
MODALIAS=hid:b0003g0001v0000046Dp0000C51A
SEQNUM=3147
SUBSYSTEM=hid
UDEV_LOG=3
USEC_INITIALIZED=21728397927
UDEV [21728.398650] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C51A.004B/hidraw/hidraw2 (hidraw)
ACTION=add
DEVNAME=/dev/hidraw2
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C51A.004B/hidraw/hidraw2
MAJOR=251
MINOR=2
SEQNUM=3145
SUBSYSTEM=hidraw
UDEV_LOG=3
USEC_INITIALIZED=21728398188
UDEV [21728.399406] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:046D:C51A.004C/hidraw/hidraw3 (hidraw)
ACTION=add
DEVNAME=/dev/hidraw3
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:046D:C51A.004C/hidraw/hidraw3
MAJOR=251
MINOR=3
SEQNUM=3151
SUBSYSTEM=hidraw
UDEV_LOG=3
USEC_INITIALIZED=21728399273
UDEV [21728.400119] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/usbmisc/hiddev1 (usbmisc)
ACTION=add
DEVNAME=/dev/usb/hiddev1
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/usbmisc/hiddev1
MAJOR=180
MINOR=1
SEQNUM=3150
SUBSYSTEM=usbmisc
UDEV_LOG=3
USEC_INITIALIZED=21727874845
UDEV [21728.401438] add /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input73 (input)
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input73
EV=17
ID_BUS=usb
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c51a
ID_PATH=pci-0000:00:1d.0-usb-0:1.3:1.0
ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_3_1_0
ID_REVISION=4100
ID_SERIAL=Logitech_USB_Receiver
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030102:030000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
KEY=ffff0000 0 0 0 0
MODALIAS=input:b0003v046DpC51Ae0111-e0,1,2,4,k110,111,112,113,114,115,116,117,118,119,11A,11B,11C,11D,11E,11F,r0,1,6,8,am4,lsfw
MSC=10
NAME="Logitech USB Receiver"
PHYS="usb-0000:00:1
udevadm monitor --environment --udev
수신기 제거시 출력 :
#######REMOVE#######
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
UDEV [21800.789239] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input75/mouse1 (input)
ACTION=remove
DEVLINKS=/dev/input/by-id/usb-Logitech_USB_Receiver-mouse /dev/input/by-path/pci-0000:00:1d.0-usb-0:1.3:1.0-mouse
DEVNAME=/dev/input/mouse1
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input75/mouse1
ID_BUS=usb
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c51a
ID_PATH=pci-0000:00:1d.0-usb-0:1.3:1.0
ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_3_1_0
ID_REVISION=4100
ID_SERIAL=Logitech_USB_Receiver
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030102:030000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
MAJOR=13
MINOR=33
SEQNUM=3178
SUBSYSTEM=input
UDEV_LOG=3
USEC_INITIALIZED=21797014959
UDEV [21800.792866] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input75/event6 (input)
ACTION=remove
DEVLINKS=/dev/input/by-id/usb-Logitech_USB_Receiver-event-mouse /dev/input/by-path/pci-0000:00:1d.0-usb-0:1.3:1.0-event-mouse
DEVNAME=/dev/input/event6
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input75/event6
ID_BUS=usb
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c51a
ID_PATH=pci-0000:00:1d.0-usb-0:1.3:1.0
ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_3_1_0
ID_REVISION=4100
ID_SERIAL=Logitech_USB_Receiver
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030102:030000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
MAJOR=13
MINOR=70
SEQNUM=3179
SUBSYSTEM=input
UDEV_LOG=3
USEC_INITIALIZED=21797013896
UDEV [21800.797061] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input75 (input)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/input/input75
EV=17
ID_BUS=usb
ID_INPUT=1
ID_INPUT_MOUSE=1
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c51a
ID_PATH=pci-0000:00:1d.0-usb-0:1.3:1.0
ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_3_1_0
ID_REVISION=4100
ID_SERIAL=Logitech_USB_Receiver
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030102:030000:
ID_USB_INTERFACE_NUM=00
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
KEY=ffff0000 0 0 0 0 0 0 0 0
MODALIAS=input:b0003v046DpC51Ae0111-e0,1,2,4,k110,111,112,113,114,115,116,117,118,119,11A,11B,11C,11D,11E,11F,r0,1,6,8,am4,lsfw
MSC=10
NAME="Logitech USB Receiver"
PHYS="usb-0000:00:1d.0-1.3/input0"
PRODUCT=3/46d/c51a/111
PROP=0
REL=143
SEQNUM=3180
SUBSYSTEM=input
UDEV_LOG=3
UNIQ=""
USEC_INITIALIZED=21796479085
UDEV [21800.797132] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C51A.004D/hidraw/hidraw2 (hidraw)
ACTION=remove
DEVNAME=/dev/hidraw2
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C51A.004D/hidraw/hidraw2
MAJOR=251
MINOR=2
SEQNUM=3181
SUBSYSTEM=hidraw
UDEV_LOG=3
USEC_INITIALIZED=21800796369
UDEV [21800.797172] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C51A.004D (hid)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C51A.004D
HID_ID=0003:0000046D:0000C51A
HID_NAME=Logitech USB Receiver
HID_PHYS=usb-0000:00:1d.0-1.3/input0
MODALIAS=hid:b0003g0001v0000046Dp0000C51A
SEQNUM=3182
SUBSYSTEM=hid
UDEV_LOG=3
USEC_INITIALIZED=21800796501
UDEV [21800.798537] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0 (usb)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0
DEVTYPE=usb_interface
INTERFACE=3/1/2
MODALIAS=usb:v046DpC51Ad4100dc00dsc00dp00ic03isc01ip02in00
PRODUCT=46d/c51a/4100
SEQNUM=3183
SUBSYSTEM=usb
TYPE=0/0/0
UDEV_LOG=3
USEC_INITIALIZED=21800796538
UDEV [21800.814181] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/input/input76/event7 (input)
ACTION=remove
DEVLINKS=/dev/input/by-id/usb-Logitech_USB_Receiver-event-if01 /dev/input/by-path/pci-0000:00:1d.0-usb-0:1.3:1.1-event
DEVNAME=/dev/input/event7
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/input/input76/event7
ID_BUS=usb
ID_INPUT=1
ID_INPUT_KEY=1
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c51a
ID_PATH=pci-0000:00:1d.0-usb-0:1.3:1.1
ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_3_1_1
ID_REVISION=4100
ID_SERIAL=Logitech_USB_Receiver
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030102:030000:
ID_USB_INTERFACE_NUM=01
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
MAJOR=13
MINOR=71
SEQNUM=3184
SUBSYSTEM=input
UDEV_LOG=3
USEC_INITIALIZED=21797013933
XKBLAYOUT=de
XKBMODEL=pc105
UDEV [21800.816765] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/input/input76 (input)
ABS=1 0
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/input/input76
EV=1f
ID_BUS=usb
ID_INPUT=1
ID_INPUT_KEY=1
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c51a
ID_PATH=pci-0000:00:1d.0-usb-0:1.3:1.1
ID_PATH_TAG=pci-0000_00_1d_0-usb-0_1_3_1_1
ID_REVISION=4100
ID_SERIAL=Logitech_USB_Receiver
ID_TYPE=hid
ID_USB_DRIVER=usbhid
ID_USB_INTERFACES=:030102:030000:
ID_USB_INTERFACE_NUM=01
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
KEY=4837fff 72ff32d bf544446 0 0 1 20f90 8b17c000 677bfa d9415fed 9ed680 4400 0 10000002
MODALIAS=input:b0003v046DpC51Ae0111-e0,1,2,3,4,k71,72,73,74,77,80,82,83,85,86,87,88,89,8A,8B,8C,8E,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B0,B1,B2,B5,B6,CE,CF,D0,D1,D2,D4,D8,D9,DB,DF,E4,E7,E8,E9,EA,EB,F1,100,161,162,166,16A,16E,172,174,176,178,179,17A,17B,17C,17D,17F,180,182,183,185,188,189,18C,18D,18E,18F,190,191,192,193,195,198,199,19A,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,1BA,r6,a20,m4,lsfw
MSC=10
NAME="Logitech USB Receiver"
PHYS="usb-0000:00:1d.0-1.3/input1"
PRODUCT=3/46d/c51a/111
PROP=0
REL=40
SEQNUM=3185
SUBSYSTEM=input
UDEV_LOG=3
UNIQ=""
USEC_INITIALIZED=21796482192
UDEV [21800.817249] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/usbmisc/hiddev1 (usbmisc)
ACTION=remove
DEVNAME=/dev/usb/hiddev1
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/usbmisc/hiddev1
MAJOR=180
MINOR=1
SEQNUM=3186
SUBSYSTEM=usbmisc
UDEV_LOG=3
USEC_INITIALIZED=21800816392
UDEV [21800.818490] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:046D:C51A.004E/hidraw/hidraw3 (hidraw)
ACTION=remove
DEVNAME=/dev/hidraw3
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:046D:C51A.004E/hidraw/hidraw3
MAJOR=251
MINOR=3
SEQNUM=3187
SUBSYSTEM=hidraw
UDEV_LOG=3
USEC_INITIALIZED=21800816472
UDEV [21800.818536] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:046D:C51A.004E (hid)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:046D:C51A.004E
HID_ID=0003:0000046D:0000C51A
HID_NAME=Logitech USB Receiver
HID_PHYS=usb-0000:00:1d.0-1.3/input1
MODALIAS=hid:b0003g0001v0000046Dp0000C51A
SEQNUM=3188
SUBSYSTEM=hid
UDEV_LOG=3
USEC_INITIALIZED=21800816908
UDEV [21800.818580] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1 (usb)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1
DEVTYPE=usb_interface
INTERFACE=3/0/0
MODALIAS=usb:v046DpC51Ad4100dc00dsc00dp00ic03isc00ip00in01
PRODUCT=46d/c51a/4100
SEQNUM=3189
SUBSYSTEM=usb
TYPE=0/0/0
UDEV_LOG=3
USEC_INITIALIZED=21800816945
UDEV [21800.818645] remove /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3 (usb)
ACTION=remove
BUSNUM=002
DEVNAME=/dev/bus/usb/002/038
DEVNUM=038
DEVPATH=/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=USB_Receiver
ID_MODEL_ENC=USB\x20Receiver
ID_MODEL_ID=c51a
ID_REVISION=4100
ID_SERIAL=Logitech_USB_Receiver
ID_USB_INTERFACES=:030102:030000:
ID_VENDOR=Logitech
ID_VENDOR_ENC=Logitech
ID_VENDOR_ID=046d
MAJOR=189
MINOR=165
PRODUCT=46d/c51a/4100
SEQNUM=3190
SUBSYSTEM=usb
TYPE=0/0/0
UDEV_LOG=3
UPOWER_VENDOR=Logitech, Inc.
USEC_INITIALIZED=21796488421
udevadm test --action=add $(udevadm info --query=path -n /dev/input/mouse0)