I like to switch between my HHKB and my IBM SSK from time to time (and sometimes I need to use my laptop's keyboard). My problem: I need the Super-key (Windows-key) quite often, and for that I am remapping CTRL to CapsLock on the SSK, and make the left CTRL a Super key.
Of course, these changes are not necessary on the HHKB, and I don't want the HHKBs CTRL to behave like a Super key. Does anyone know if I can have my system detect which keyboard is plugged in and set the Xmodmap dynamically depending on that?
Linux: change Xmodmap depending on keyboard plugged in?
- matt3o
- -[°_°]-
- Location: Italy
- Main keyboard: WhiteFox
- Main mouse: Anywhere MX
- Favorite switch: Anything, really
- DT Pro Member: 0030
- Contact:
it seems a job for udev. I don't know your distro I'll try to be generic.
Basically you have to find the device with lsusb or dmesg. You can identify the keyboard in many ways, the easiest is probably by ID. It's in the form of xxxx:yyyy. where xxxx is the vendor and yyyy the device itself.
Then you create a new rule (a text file) in /etc/udev/rules.d/98-user.rules
In that file you place something like this (please verify I didn't check it)
of course replace xxxx and yyyy with the keyboards ID and /path/to/your/script.sh with the script to execute.
I didn't check it, but should work. Google it, you'll find dozens tutorials.
Basically you have to find the device with lsusb or dmesg. You can identify the keyboard in many ways, the easiest is probably by ID. It's in the form of xxxx:yyyy. where xxxx is the vendor and yyyy the device itself.
Then you create a new rule (a text file) in /etc/udev/rules.d/98-user.rules
In that file you place something like this (please verify I didn't check it)
Code: Select all
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="xxxx", SYSFS{idProduct}=="yyyy", ACTION=="add", RUN+="/path/to/your/script.sh"
I didn't check it, but should work. Google it, you'll find dozens tutorials.
Last edited by matt3o on 13 Apr 2013, 17:56, edited 1 time in total.
-
- Main keyboard: IBM Model M
- Main mouse: Masamune Shirow
- Favorite switch: Buckling springs
- DT Pro Member: -
- Contact:
mSSM: if you get it to work (for example following matt3o's infos), could you do a recap here?
I'd like to do the same (with xkbcomp instead of Xmodmap but I take it that's not the "hard" part)
I'd like to do the same (with xkbcomp instead of Xmodmap but I take it that's not the "hard" part)
-
- Location: Stockholm, Sweden
- DT Pro Member: 0011
You will also need a rule for when you disconnect the SSK.
- matt3o
- -[°_°]-
- Location: Italy
- Main keyboard: WhiteFox
- Main mouse: Anywhere MX
- Favorite switch: Anything, really
- DT Pro Member: 0030
- Contact:
same as above but with ACTION=="remove"Findecanor wrote:You will also need a rule for when you disconnect the SSK.