Permanently set keyboard layout options with setxkbmap in gnome/unity

149

Solution 1

To prevent gnome resetting keyboard setting in X i use this command:

gsettings set org.gnome.settings-daemon.plugins.keyboard active false

This works for me.

Solution 2

I've been going nuts over this just like you, but with Ubuntu 14.04 (LTS), Xubuntu, xfce 4.12 and xkbd (from xfce goodies). Ctrl+Space to change the keyboard layout worked, but Alt+Shift didn't (modifier-only keys).

Finally managed to make things work-

1. Run ibus-setup (Keyboard Input Methods application).
2. Goto Advanced tab.
3. Check 'Use system keyboard layout'.
4. Click 'Close'

5. Run xfce4-keyboard-settings (Keyboard application).
6. Goto Layout tab.
7. Uncheck 'Use system defaults'
8. Select 'Keyboard model' (typically 'Generic 105-key (Intl) PC' will do)
9. Set 'Change layout option' to your required switching keys combination (typically Alt+Shift will do).
10. Add languages to 'Keyboard layout'.
11. Click 'Close'.
12. Restart the computer

You're done! Use Alt+Shift to change keyboard layout.

Solution 3

I just read this article on screenlocking, which may be related. According to the article, screenlocking has the intended consequence of blocking input devices and manipulating locales. Seems like you have a few options:

  1. Stop locking the screen, probably this includes the greeting screen as well which serves a similar function
  2. Use different power management tools
  3. Stop using ibus for im-switching (Perhaps FCITX?)
  4. Create a hook for screen unlock events as described here.

There is an interesting discussion of this and related events which can be found on the ubuntu-dev mailing list: https://lists.ubuntu.com/archives/ubuntu-devel/2013-November/037768.html

Solution 4

Workaround by user wof in Ubuntu bug tracker, for Ubuntu 14.10 using gxkb:

https://bugs.launchpad.net/gnome-settings-daemon/+bug/1244090/comments/39

this workaround worked for ubuntu 14.10:

  • in Settings->Text entry remove all input sources, leave only english
  • install gxkb (layout switcher): sudo apt-get install gxkb
  • add gxkb to startup applications via gnome-tweak-tool
  • setup gxkb hotkeys in ~/.config/gxkb (default is alt_shift, but in 14.10 it doesn't work. ctrl_shift works ok)

p.s. new version of gxkb has appindicator for ubuntu. can be installed via ppa:zen-root/gxkb-stable

Share:
149

Related videos on Youtube

Abhinav Prakash
Author by

Abhinav Prakash

Updated on September 18, 2022

Comments

  • Abhinav Prakash
    Abhinav Prakash over 1 year

    I am using a Grid where the first column is checkbox. Every row is a folder which can have many other elements to be selected. There could be another folder inside a folder.

    Now, when I have to select a element I have to select it one by one. I am not able to understand that how could I make it possible that if I check a folder checkbox, It checks the all selectable elements inside this folder.

    Please let me know if more info required.

        RemoteSortTreeLoader<BasicModel> loader = 
            new BaseRemoteSortTreeLoader<BasicModel>(proxy, reader) {                   
                public boolean hasChildren(BasicModel parent) {                 
                    //code;
                }
            };
        TreeStore store = new TreeStore(loader);        
        List<ColumnConfig> columnList = new ArrayList<ColumnConfig>();      
        CheckBoxSelectionModel checkBoxSelectionModel = 
            new CheckBoxSelectionModel();
        columnList.add(checkBoxSelectionModel.getColumn());
        ColumnModel columns = new ColumnModel(columnList);
        EditorTreeGrid grid = new EditorTreeGrid<BasicModel>(store,columns);
        grid.getSelectionModel().setSelectionMode(SelectionMode.SIMPLE);
        grid.getSelectionModel().addListener(Events.BeforeSelect, 
            new Listener<SelectionEvent<BasicModel>>() {
                @Override
                public void handleEvent(SelectionEvent<BasicModel> event) {                 
                    if (event.getModel() instanceof SDPTimelineCatalogModel) {
                        event.setCancelled(false);
                        }
                } // handleEvent        
            }
        );
    
        grid.getSelectionModel().addSelectionChangedListener(
            new SelectionChangedListener<BasicModel>() {
    
                @Override
                public void selectionChanged(SelectionChangedEvent<BasicModel> event) {
                    logger.info(" Inside addSelectionChangedListener ");
                    if (event.getSelection().size() == 0) {
                        disableNext();
                    } else {
                        enableNext();                       
                    }
    
                } // selectionChanged
    
                }
        );
    

    thanks

    • Admin
      Admin about 10 years
      Have you tried setting the layout correctly in gnome and then adding the two setxkbmap commands to your ~/.profile? That way, they will be run each time you log in and since the same settings are there in Gnome, it should not change anything if it resets.
    • Admin
      Admin about 10 years
      @terdon it resets even after screen lock. And it resets to "us-only, no switch" state, not to settings defined in org.gnome.desktop.input-sources.
    • Admin
      Admin about 10 years
      Strange. Are you sure you are using Gnome and not Unity? Have you tried changing the settings through the normal GUI instead of dconf-editor?
    • Admin
      Admin about 10 years
      @terdon yes, it is unity, but it uses lost of gnome's stuff, like gnome-settings-daemon, which possily resets keymap.
    • Admin
      Admin about 10 years
      So, have you tried setting the correct settings from the Unity GUI?
    • Admin
      Admin about 10 years
      @terdon unity GUI does not set xkbmap correctly, it uses its own switcher that intercepts keypresses and switch keyboard. It is slow and causes focus to being loss when key is pressed.
    • Admin
      Admin over 9 years
    • Admin
      Admin over 9 years
      Something not related with your problem: Which theme is this?
    • Admin
      Admin over 9 years
      Setting the xkb-options field to ['altwin:swap_alt_win'] in dconf-editor works in ubuntu 14.10 (unity) to have this xkboption remain after switching the keyboard layout (e.g. english -> french etc). In contrast, setxkbmap -option does't work for that, this cmd has to be re-issued each time. Not quite sure if this helps your problem - this is just to say that it appears that org.gnome.desktop.input-sources is what matters when the keyboard layout is switched (at least on unity)
    • Admin
      Admin almost 9 years
      xmodmap is possible solution although is certainly reset on restart. This should set it to Dvorak wget -qO- http://pastebin.com/raw.php?i=t2Ndf1Zw | xmodmap -
    • Admin
      Admin over 8 years
      Found localectl but it doesn't persist, either. Did you find a solution that persists after reboot and lock screen? I am looking for a command line, scriptable one myself.
  • kolen
    kolen about 9 years
    (Not tried it yet)
  • Nickolai Leschov
    Nickolai Leschov over 8 years
    Why do you recommend using xfce4-keyboard-settings in the question asking for help with gnome/unity, specifically?
  • Nickolai Leschov
    Nickolai Leschov over 8 years
    I tried this on Ubuntu 14.04 and it does nothing. Do you have any explaination re: how this is supposed to work?
  • ndemou
    ndemou over 8 years
    Works for me in 14.04
  • e18r
    e18r over 8 years
    E: Unable to locate package gxkb
  • Leonardo Castro
    Leonardo Castro over 7 years
    Works for me in 16.04, after trying everything else.
  • Cnly
    Cnly over 6 years
    The only method I found working in 17.04.
  • dragon788
    dragon788 over 6 years
    Keep in mind Ubuntu had actually created a unity-settings-daemon for a period of time as well, but now that they are going back to Gnome again this might keep working.