Search code examples
linuxkeyboardidedebian

How can I force changing the keyboard layout in Linux in IDE?


When I upgraded to debian 12, I have new problem with jetbreans and netbeans ide, These java application can't change keyboard layouts, when I change keyboard layout to Swedish for one moment then back to English immediately!

So my problem is: I can't change keyboard layout in all IDE's based on java, how to fix this problem in ide?

BTW, I flowed this topic and other topics look like this:

https://youtrack.jetbrains.com/issue/IDEA-254960/Keyboard-shortcuts-dont-follow-layout-changes-under-ubuntu-gnome


Solution

  • It's depends on you NVIDIA drivers, I have write about this on my life blog

    Summery

    There is no usual solution to fix this problem completely, but You, can use my alternative solution:

    test setxkbmap

    $ sudo apt-get install x11-xkb-utils
    $ setxkbmap -query
    
    rules: evdev
    model: pc105
    layout: us,ir
    

    then you can change you language manual: ( you can replace your language here like sv or ru instead ir)

    $ setxkbmap us,ir
    $ setxkbmap ir,us
    

    Then install ‍xkblayout-state:

    $ sudo apt-get install libx11-dev git
    $ mkdir temp
    $ cd temp
    $ git clone https://github.com/nonpop/xkblayout-state.git
    $ cd xkblayout-state
    $ make
    $ make install
    

    now you have to make new file key.sh in safe path where you don't rename this or parent folders with this content:

    Don't forget replace ir with your lang like sv:

    #!/bin/bash
    
    outkbd=$(xkblayout-state print "%s")
    uskbd="us"
    #echo $outkbd
    
    if [[ "$outkbd" == "$uskbd" ]]
    then
    #echo "us" switch to ir
    setxkbmap ir,us
    else
    #echo "ir" witch to us
    setxkbmap us,ir
    
    fi
    

    Now make it executable:

    $ chmod +x key.sh
    

    Finally define new shortcut for this and use it in your ide like this: enter image description here