You are not logged in.

#1 2010-09-22 09:49:21

xelados
Member
Registered: 2007-06-02
Posts: 314
Website

[SOLVED]Keep xset and xmodmap settings persistence upon USB disconnect

I recently bought a TypeMatrix 2030 keyboard and after making my mouse sensitivity dependent upon my USB mouse's status, I figured I'd try it on the keyboard as well. However, I'm having a much harder time of figuring out how I need to craft my rule. I'll probably be saving this for the weekend, but I'll dump the info now:

First things first, the keyboard registers two device paths under /dev/input/by-path/:

total 0
lrwxrwxrwx 1 root root 10 Sep 22 02:26 usb-Logitech_USB-PS_2_Optical_Mouse-event-mouse -> ../event11
lrwxrwxrwx 1 root root  9 Sep 22 02:26 usb-Logitech_USB-PS_2_Optical_Mouse-mouse -> ../mouse1
lrwxrwxrwx 1 root root 10 Sep 22 04:34 usb-TypeMatrix.com_USB_Keyboard-event-if01 -> ../event10
lrwxrwxrwx 1 root root  9 Sep 22 04:34 usb-TypeMatrix.com_USB_Keyboard-event-kbd -> ../event9

I have no clue which one to zero in on, but I went with the one with the "-kbd" suffix since it just makes sense.

Here's the output from udevadm on both:

-if01:

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.2/usb4/4-1/4-1:1.1/input/input63/event10':
    KERNEL=="event10"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.1/input/input63':
    KERNELS=="input63"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{name}=="TypeMatrix.com USB Keyboard"
    ATTRS{phys}=="usb-0000:00:1d.2-1/input1"
    ATTRS{uniq}==""
    ATTRS{modalias}=="input:b0003v1E54p2030e0110-e0,1,2,3,4,k71,72,73,74,77,80,82,83,85,86,87,88,89,8A,8B,8C,8E,8F,90,96,98,9B,9C,9E,9F,A1,A3,A4,A5,A6,A7,A8,A9,AB,AC,AD,AE,B1,B2,B5,B6,CE,CF,D0,D1,D2,D5,D8,D9,DB,DF,E2,E7,E8,E9,EA,EB,100,162,166,16A,16E,178,179,17A,17B,17C,17D,17F,180,181,182,185,18C,18D,192,193,195,1A0,1A1,1A2,1A3,1A4,1A5,1A6,1A7,1A8,1A9,1AA,1AB,1AC,1AD,1AE,1B0,1B1,1B7,r6,a20,m4,lsfw"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.1':
    KERNELS=="4-1:1.1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceNumber}=="01"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{modalias}=="usb:v1E54p2030d0130dc00dsc00dp00ic03isc01ip00"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1':
    KERNELS=="4-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{urbnum}=="22"
    ATTRS{idVendor}=="1e54"
    ATTRS{idProduct}=="2030"
    ATTRS{bcdDevice}=="0130"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="1.5"
    ATTRS{busnum}=="4"
    ATTRS{devnum}=="29"
    ATTRS{devpath}=="1"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="TypeMatrix.com"
    ATTRS{product}=="USB Keyboard"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4':
    KERNELS=="usb4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{urbnum}=="684"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0001"
    ATTRS{bcdDevice}=="0206"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="4"
    ATTRS{devnum}=="1"
    ATTRS{devpath}=="0"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="2"
    ATTRS{quirks}=="0x0"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 2.6.35-ARCH uhci_hcd"
    ATTRS{product}=="UHCI Host Controller"
    ATTRS{serial}=="0000:00:1d.2"
    ATTRS{authorized_default}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2':
    KERNELS=="0000:00:1d.2"
    SUBSYSTEMS=="pci"
    DRIVERS=="uhci_hcd"
    ATTRS{vendor}=="0x8086"
    ATTRS{device}=="0x27ca"
    ATTRS{subsystem_vendor}=="0x144d"
    ATTRS{subsystem_device}=="0xca00"
    ATTRS{class}=="0x0c0300"
    ATTRS{irq}=="18"
    ATTRS{local_cpus}=="ff"
    ATTRS{local_cpulist}=="0-7"
    ATTRS{modalias}=="pci:v00008086d000027CAsv0000144Dsd0000CA00bc0Csc03i00"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

And -kbd:

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.2/usb4/4-1/4-1:1.0/input/input62/event9':
    KERNEL=="event9"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0/input/input62':
    KERNELS=="input62"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{name}=="TypeMatrix.com USB Keyboard"
    ATTRS{phys}=="usb-0000:00:1d.2-1/input0"
    ATTRS{uniq}==""
    ATTRS{modalias}=="input:b0003v1E54p2030e0110-e0,1,4,11,14,k71,72,73,74,75,77,79,7A,7B,7C,7D,7E,7F,80,81,82,83,84,85,86,87,88,89,8A,B7,B8,B9,BA,BB,BC,BD,BE,BF,C0,C1,C2,F0,ram4,l0,1,2,sfw"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0':
    KERNELS=="4-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{bInterfaceProtocol}=="01"
    ATTRS{modalias}=="usb:v1E54p2030d0130dc00dsc00dp00ic03isc01ip01"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4/4-1':
    KERNELS=="4-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{urbnum}=="22"
    ATTRS{idVendor}=="1e54"
    ATTRS{idProduct}=="2030"
    ATTRS{bcdDevice}=="0130"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="1.5"
    ATTRS{busnum}=="4"
    ATTRS{devnum}=="29"
    ATTRS{devpath}=="1"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="TypeMatrix.com"
    ATTRS{product}=="USB Keyboard"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2/usb4':
    KERNELS=="usb4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{urbnum}=="684"
    ATTRS{idVendor}=="1d6b"
    ATTRS{idProduct}=="0001"
    ATTRS{bcdDevice}=="0206"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{speed}=="12"
    ATTRS{busnum}=="4"
    ATTRS{devnum}=="1"
    ATTRS{devpath}=="0"
    ATTRS{version}==" 1.10"
    ATTRS{maxchild}=="2"
    ATTRS{quirks}=="0x0"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{authorized}=="1"
    ATTRS{manufacturer}=="Linux 2.6.35-ARCH uhci_hcd"
    ATTRS{product}=="UHCI Host Controller"
    ATTRS{serial}=="0000:00:1d.2"
    ATTRS{authorized_default}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:1d.2':
    KERNELS=="0000:00:1d.2"
    SUBSYSTEMS=="pci"
    DRIVERS=="uhci_hcd"
    ATTRS{vendor}=="0x8086"
    ATTRS{device}=="0x27ca"
    ATTRS{subsystem_vendor}=="0x144d"
    ATTRS{subsystem_device}=="0xca00"
    ATTRS{class}=="0x0c0300"
    ATTRS{irq}=="18"
    ATTRS{local_cpus}=="ff"
    ATTRS{local_cpulist}=="0-7"
    ATTRS{modalias}=="pci:v00008086d000027CAsv0000144Dsd0000CA00bc0Csc03i00"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

And finally, my current rule, which doesn't work:

KERNEL=="event*", SUBSYSTEM=="input", ATTRS{manufacturer}=="TypeMatrix.com", ATTRS{product}=="USB Keyboard", RUN+="xmodmap -display :0.0 ~/.Xmodmap; xset r rate 200 30"

Hopefully I'm not missing something obvious like I was with the mouse. If anyone could help me figure this out I'd be grateful. Searching the Web, forums, and wiki did not help.

SOLUTION:
See my last post.

Last edited by xelados (2010-10-12 03:23:03)

Offline

#2 2010-09-22 21:32:04

Owen Tuz
Member
Registered: 2010-09-16
Posts: 12

Re: [SOLVED]Keep xset and xmodmap settings persistence upon USB disconnect

xelados wrote:

.. after making my mouse sensitivity dependent upon my USB mouse's status...

Does this mean you have a working udev rule for your mouse? I only ask as this should help us identify whether this is a general hotplugging program or something more specific.

If you are already successfully using a udev rule for your mouse, could you try something along the lines of the following for me please (making sure it's all on one line)?

KERNEL=="event*", SUBSYSTEM=="input", ENV{DISPLAY}=":0.0", ATTRS{manufacturer}=="TypeMatrix.com", ATTRS{product}=="USB Keyboard", 
RUN+="xmodmap ~/.Xmodmap && xset r rate 200 30"

Good luck!

Last edited by Owen Tuz (2010-09-22 21:33:30)

Offline

#3 2010-09-23 09:22:19

xelados
Member
Registered: 2007-06-02
Posts: 314
Website

Re: [SOLVED]Keep xset and xmodmap settings persistence upon USB disconnect

Owen Tuz wrote:
xelados wrote:

.. after making my mouse sensitivity dependent upon my USB mouse's status...

Does this mean you have a working udev rule for your mouse? I only ask as this should help us identify whether this is a general hotplugging program or something more specific.

If you are already successfully using a udev rule for your mouse, could you try something along the lines of the following for me please (making sure it's all on one line)?

KERNEL=="event*", SUBSYSTEM=="input", ENV{DISPLAY}=":0.0", ATTRS{manufacturer}=="TypeMatrix.com", ATTRS{product}=="USB Keyboard", RUN+="xmodmap ~/.Xmodmap && xset r rate 200 30"

Good luck!

Yes, the udev rule I wrote for my mouse works.

I just tried your rule and it did not work...

Offline

#4 2010-09-23 10:28:32

Owen Tuz
Member
Registered: 2010-09-16
Posts: 12

Re: [SOLVED]Keep xset and xmodmap settings persistence upon USB disconnect

Ok, I've just discovered this sentence in the Wiki:

Currently there is no way to autoconfigure keymaps for hotplugged keyboards.

Now, the wiki page is flagged as out of date, and even then it's not written in stone, so I'm not going to tell you it can't be done. But if anyone knows any more about this, I'd be interested to hear it.

If you want to keep trying - have you tried focusing on the -if01 instance yet?

From http://wiki.archlinux.org/index.php/Xor … leshooting :

I configured my mouse and/or keyboard in xorg.conf, but X will not use it

When input hotplugging is enabled, X will purge any devices setup in xorg.conf that are using the kbd and mouse driver.

I know that when you're making a new rule, udev prioritises based on the number at the start (eg 10-x11-synaptics etc). Lower numbers have higher priority, but perhaps "event10" reads in as "event 1 with a zero after it" (if you understand me) and is prioritised over "event9"? If that's the case, it might well make sense to focus on -if01.

Offline

#5 2010-09-24 07:37:17

xelados
Member
Registered: 2007-06-02
Posts: 314
Website

Re: [SOLVED]Keep xset and xmodmap settings persistence upon USB disconnect

That is an interesting point.. I'll give it a shot. Currently I'm using /etc/udev/rules.d/00.rules

Offline

#6 2010-10-12 02:02:14

xelados
Member
Registered: 2007-06-02
Posts: 314
Website

Re: [SOLVED]Keep xset and xmodmap settings persistence upon USB disconnect

Well, I've since attempted to target -if01 with no luck, so I sought alternatives, such as kbdrate and manually setting it under xorg's config. Still no dice... I'm continuing to see if udev can solve this, since it worked just fine with fixing the behavior of my mouse.

UPDATE: To test, I checked to see if I could symlink the kbd. That worked, so that tells me the device CAN be picked up by udev. I just need to convince it to run those commands...

Current rule is:

ATTRS{name}=="TypeMatrix.com USB Keyboard", SYMLINK+="typematrix", ENV{DISPLAY}=":0.0", RUN+="xcowsay yay"

I don't get my silly cow when it's plugged in for affirmation sad

UPDATE2: Halfway done! I noticed that my mouse rule was using the complete path for the app I was calling. However, I can't seem to add a second command to the RUN key. I'll try writing a bash script.

SOLVED: Making a script fixed it! It seems that udev needs a complete path to the script/app and only one!

ATTRS{name}=="TypeMatrix.com USB Keyboard", SYMLINK+="typematrix", ENV{DISPLAY}=":0.0", RUN+="/home/xelados/bin/typematrix"

~/bin/typematrix has:

xmodmap /home/xelados/.Xmodmap
xset r rate 200 30

Interesting that I didn't have to supply the full path when inside the bash script.

Last edited by xelados (2010-10-12 03:20:12)

Offline

#7 2010-10-18 10:57:41

loci
Member
Registered: 2008-05-11
Posts: 4

Re: [SOLVED]Keep xset and xmodmap settings persistence upon USB disconnect

I always used .Xmodmap to swap escape and caps, recently the mechanism became unstable.  I also had a problem where the fdi rule to set my keyboard to dvorak was not honored.

It seems that since Xorg 1.8.0 the mechanisms have been changed and the best way to achieve these things now is through /etc/xorg.conf

Here is mine. It sets my layout to dvorak and  caps as escape:

Section "InputClass"
    Identifier             "Keyboard Defaults"
    MatchIsKeyboard       "yes"
    Option               "XkbLayout" "dvorak"
    Option           "XkbOptions" "caps:swapescape,terminate:ctrl_alt_bksp"
EndSection

This is the whole file not just a snippet.  I don't need xorg.conf for display and other purposes everything else works.

These settings survives hot plugging the keyboard.

Offline

#8 2010-10-21 03:40:05

xelados
Member
Registered: 2007-06-02
Posts: 314
Website

Re: [SOLVED]Keep xset and xmodmap settings persistence upon USB disconnect

Sweet, loci! Can that be tweaked to account for keyboard repeat delay and speed? udev is useful and powerful, but a bitch and a half to config.

Offline

#9 2010-10-21 04:59:41

loci
Member
Registered: 2008-05-11
Posts: 4

Re: [SOLVED]Keep xset and xmodmap settings persistence upon USB disconnect

It seems you could before: http://www.netbsd.org/docs/guide/en/cha … x-keyboard

But this seems to not work anymore.  According to this bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=601853
Doing it with udev or with some daemon is now required.  :-(

Last edited by loci (2010-10-21 05:30:55)

Offline

Board footer

Powered by FluxBB