2

I set my keyboard layout like this:

setxkbmap -layout us -variant altgr-intl -option '' -option caps:escape -option altwin:swap_alt_win lv3:rwin_switch

which is fine, as long as I do not plugin and plug out an external keyboard, or hit the "switch keyboard layout" key. In these cases I have to go to the terminal and redo this command.

I would like this options to be more permanent, so I try to set them in the "tweak tool". But I cannot find an option, that correspond to "lv3:rwin_switch" which sets my lv3 key (for international characters) to my right win key.

I tried around, but the options are a little confusing. Can this be done in the tweak-tool?

1 Answer 1

0

Perhaps adding a udev rule to run the same command when keyboard commands may solve the problem.

  1. First connect your external keyboard, and do lsusb to find the hardware ID. It would look something like

    Bus 002 Device 002: ID 04f2:0402 Chicony Electronics Co., Ltd Genius LuxeMate i200 Keyboar. The id is 04f2:0402.

  2. Then we add a UDEV rule. To edit the file, do sudo nano /etc/udev/rules.d/00-usb-keyboards.rules, fill the text file with something like

    ACTION=="add", ATTRS{idVendor}=="YOUR_VENDOR(04f2 for me)", ATTRS{idProduct}=="YOUR_PRODUCT(0402 for me)", RUN+="/usr/local/bin/kbd_udev", OWNER="USERNAME"
    

    Note that you should change the USERNAME field. And with this we tell udev to run the script whenever the device with matching vendor and product ID is connected.

  3. Now we get to the script file /usr/local/bin/kbd_udev, do sudo nano /usr/local/bin/kbd_udev and fill it in with the script below

    #!/bin/bash
    export DISPLAY=:0
    su YOURUSERNAME -c "setxkbmap -layout us -variant altgr-intl -option '' -option caps:escape -option altwin:swap_alt_win lv3:rwin_switch" &> /tmp/kbd_temp
    

    Again, make sure to change YOURUSERNAME with your username.

  4. After writing the script, you need to make it executable. To do so..

    sudo chmod 755 /usr/local/bin/kbd_udev
    
  5. Finally, tell udev to reload it's rules, run udevadm control --reload-rules

  6. Optional, but you can test to see if the command worked, by looking in the /tmp/ directory. Do cat /tmp/kbd_temp, if there are any errors, you should be able to see them.

2
  • Your answer seems to stop abruptly. My keyboard is this: Bus 001 Device 010: ID 1241:1503 Belkin Keyboard
    – Nathan
    Jun 11, 2015 at 13:01
  • Yeah sorry, it got submitted before I finished editing it. Could you try the next steps and tell what you get ?
    – hingev
    Jun 11, 2015 at 13:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .