How to gracefully change keyboard layout from command line (setxkbmap breaks all shortcuts)












2














Is there a way to change the currently active keyboard layout in Cinnamon, from command line?



The setxkbmap solution that most of the guides suggest, doesn't quite work as it is supposed to:
If it is called, the language indicator in Cinnamon itself dissapears, and the existing combinations configured in Cinnamon do not work any more. To restore this functionality, one has to go to the settings and re-enable any of the keyboard layout setting.



Additionally, the way setxkbmap seems to change the layout is of a nature of being lower level than Cinnamon seems to like: for example if you change a layout to a non-latin one, using setxkbmap, the default key combinations in the whole system stop working. (easily tested with Ctrl-C). This never happens with the native layout switching from within Cinnamon. It appears that setxkbmap operates at a lower level than what most applications expect.



Is there a way to change the layout the native, Cinnamon (or gnome, since it's based on it?) way and keep the keyboard combinations working?



(Another solution usually proposed is gsettings set org.gnome.desktop.input-sources current 0, which does not work either in current Cinnamon (nothing happens)).



I have of course, tested all the possible indexes, up to 10, even though I have only 3 layouts added currently. The mentioned variable does not seem to change either when the layouts are changed manually. I have also tried the similar variable that exists in Cinnamon environment, org.cinnamon.desktop.input-sources, but it does not affect anything either (in exactly the same way as the gnome version).










share|improve this question
























  • What about gsettings set org.gnome.desktop.input-sources current 1 ?
    – Gunnar Hjalmarsson
    Oct 24 '17 at 17:01










  • I have of course tested different values, I have updated my question.
    – Cray
    Oct 25 '17 at 16:05












  • At a terminal prompt, one may use the SUPER-SPACE shortcut to cycle through your keyboard layouts. Will this work for you? Or must it be a solution for scripts, alone?
    – TheGeeko61
    Oct 25 '17 at 16:29










  • Well, if that does not work for switching layout, Cinnamon seems to do it its own way, differently from Unity and GNOME. I'm not able to tell how.
    – Gunnar Hjalmarsson
    Oct 25 '17 at 18:50
















2














Is there a way to change the currently active keyboard layout in Cinnamon, from command line?



The setxkbmap solution that most of the guides suggest, doesn't quite work as it is supposed to:
If it is called, the language indicator in Cinnamon itself dissapears, and the existing combinations configured in Cinnamon do not work any more. To restore this functionality, one has to go to the settings and re-enable any of the keyboard layout setting.



Additionally, the way setxkbmap seems to change the layout is of a nature of being lower level than Cinnamon seems to like: for example if you change a layout to a non-latin one, using setxkbmap, the default key combinations in the whole system stop working. (easily tested with Ctrl-C). This never happens with the native layout switching from within Cinnamon. It appears that setxkbmap operates at a lower level than what most applications expect.



Is there a way to change the layout the native, Cinnamon (or gnome, since it's based on it?) way and keep the keyboard combinations working?



(Another solution usually proposed is gsettings set org.gnome.desktop.input-sources current 0, which does not work either in current Cinnamon (nothing happens)).



I have of course, tested all the possible indexes, up to 10, even though I have only 3 layouts added currently. The mentioned variable does not seem to change either when the layouts are changed manually. I have also tried the similar variable that exists in Cinnamon environment, org.cinnamon.desktop.input-sources, but it does not affect anything either (in exactly the same way as the gnome version).










share|improve this question
























  • What about gsettings set org.gnome.desktop.input-sources current 1 ?
    – Gunnar Hjalmarsson
    Oct 24 '17 at 17:01










  • I have of course tested different values, I have updated my question.
    – Cray
    Oct 25 '17 at 16:05












  • At a terminal prompt, one may use the SUPER-SPACE shortcut to cycle through your keyboard layouts. Will this work for you? Or must it be a solution for scripts, alone?
    – TheGeeko61
    Oct 25 '17 at 16:29










  • Well, if that does not work for switching layout, Cinnamon seems to do it its own way, differently from Unity and GNOME. I'm not able to tell how.
    – Gunnar Hjalmarsson
    Oct 25 '17 at 18:50














2












2








2







Is there a way to change the currently active keyboard layout in Cinnamon, from command line?



The setxkbmap solution that most of the guides suggest, doesn't quite work as it is supposed to:
If it is called, the language indicator in Cinnamon itself dissapears, and the existing combinations configured in Cinnamon do not work any more. To restore this functionality, one has to go to the settings and re-enable any of the keyboard layout setting.



Additionally, the way setxkbmap seems to change the layout is of a nature of being lower level than Cinnamon seems to like: for example if you change a layout to a non-latin one, using setxkbmap, the default key combinations in the whole system stop working. (easily tested with Ctrl-C). This never happens with the native layout switching from within Cinnamon. It appears that setxkbmap operates at a lower level than what most applications expect.



Is there a way to change the layout the native, Cinnamon (or gnome, since it's based on it?) way and keep the keyboard combinations working?



(Another solution usually proposed is gsettings set org.gnome.desktop.input-sources current 0, which does not work either in current Cinnamon (nothing happens)).



I have of course, tested all the possible indexes, up to 10, even though I have only 3 layouts added currently. The mentioned variable does not seem to change either when the layouts are changed manually. I have also tried the similar variable that exists in Cinnamon environment, org.cinnamon.desktop.input-sources, but it does not affect anything either (in exactly the same way as the gnome version).










share|improve this question















Is there a way to change the currently active keyboard layout in Cinnamon, from command line?



The setxkbmap solution that most of the guides suggest, doesn't quite work as it is supposed to:
If it is called, the language indicator in Cinnamon itself dissapears, and the existing combinations configured in Cinnamon do not work any more. To restore this functionality, one has to go to the settings and re-enable any of the keyboard layout setting.



Additionally, the way setxkbmap seems to change the layout is of a nature of being lower level than Cinnamon seems to like: for example if you change a layout to a non-latin one, using setxkbmap, the default key combinations in the whole system stop working. (easily tested with Ctrl-C). This never happens with the native layout switching from within Cinnamon. It appears that setxkbmap operates at a lower level than what most applications expect.



Is there a way to change the layout the native, Cinnamon (or gnome, since it's based on it?) way and keep the keyboard combinations working?



(Another solution usually proposed is gsettings set org.gnome.desktop.input-sources current 0, which does not work either in current Cinnamon (nothing happens)).



I have of course, tested all the possible indexes, up to 10, even though I have only 3 layouts added currently. The mentioned variable does not seem to change either when the layouts are changed manually. I have also tried the similar variable that exists in Cinnamon environment, org.cinnamon.desktop.input-sources, but it does not affect anything either (in exactly the same way as the gnome version).







command-line keyboard-layout cinnamon






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 25 '17 at 16:09







Cray

















asked Oct 24 '17 at 16:50









CrayCray

1607




1607












  • What about gsettings set org.gnome.desktop.input-sources current 1 ?
    – Gunnar Hjalmarsson
    Oct 24 '17 at 17:01










  • I have of course tested different values, I have updated my question.
    – Cray
    Oct 25 '17 at 16:05












  • At a terminal prompt, one may use the SUPER-SPACE shortcut to cycle through your keyboard layouts. Will this work for you? Or must it be a solution for scripts, alone?
    – TheGeeko61
    Oct 25 '17 at 16:29










  • Well, if that does not work for switching layout, Cinnamon seems to do it its own way, differently from Unity and GNOME. I'm not able to tell how.
    – Gunnar Hjalmarsson
    Oct 25 '17 at 18:50


















  • What about gsettings set org.gnome.desktop.input-sources current 1 ?
    – Gunnar Hjalmarsson
    Oct 24 '17 at 17:01










  • I have of course tested different values, I have updated my question.
    – Cray
    Oct 25 '17 at 16:05












  • At a terminal prompt, one may use the SUPER-SPACE shortcut to cycle through your keyboard layouts. Will this work for you? Or must it be a solution for scripts, alone?
    – TheGeeko61
    Oct 25 '17 at 16:29










  • Well, if that does not work for switching layout, Cinnamon seems to do it its own way, differently from Unity and GNOME. I'm not able to tell how.
    – Gunnar Hjalmarsson
    Oct 25 '17 at 18:50
















What about gsettings set org.gnome.desktop.input-sources current 1 ?
– Gunnar Hjalmarsson
Oct 24 '17 at 17:01




What about gsettings set org.gnome.desktop.input-sources current 1 ?
– Gunnar Hjalmarsson
Oct 24 '17 at 17:01












I have of course tested different values, I have updated my question.
– Cray
Oct 25 '17 at 16:05






I have of course tested different values, I have updated my question.
– Cray
Oct 25 '17 at 16:05














At a terminal prompt, one may use the SUPER-SPACE shortcut to cycle through your keyboard layouts. Will this work for you? Or must it be a solution for scripts, alone?
– TheGeeko61
Oct 25 '17 at 16:29




At a terminal prompt, one may use the SUPER-SPACE shortcut to cycle through your keyboard layouts. Will this work for you? Or must it be a solution for scripts, alone?
– TheGeeko61
Oct 25 '17 at 16:29












Well, if that does not work for switching layout, Cinnamon seems to do it its own way, differently from Unity and GNOME. I'm not able to tell how.
– Gunnar Hjalmarsson
Oct 25 '17 at 18:50




Well, if that does not work for switching layout, Cinnamon seems to do it its own way, differently from Unity and GNOME. I'm not able to tell how.
– Gunnar Hjalmarsson
Oct 25 '17 at 18:50










1 Answer
1






active

oldest

votes


















0














The best solution currently is to use this external program (xkb-switch) that accepts command line arguments and script it into xbindkeys or something similar.



Although unofficial, external, and written in a compilable language, it is actually pretty easy to install since it has almost no dependencies.



https://github.com/ierton/xkb-switch



$ xkb-switch --help

Usage: xkb-switch -s ARG Sets current layout group to ARG
xkb-switch -l|--list Displays all layout groups
xkb-switch -h|--help Displays this message
xkb-switch -v|--version Shows version number
xkb-switch -w|--wait [-p] Waits for group change and exits
xkb-switch -W Infinitely waits for group change
xkb-switch -n|--next Switch to the next layout group
xkb-switch [-p] Displays current layout group


Use as:



xkb-switch -s us
xkb-switch -s de
etc...


This solution:




  • Works from command line.

  • Is fast, invocation of this program does not introduce any delay (as opposed to switching layout setxkbmap).

  • Correctly switches the built-in layout indicator in the tray icon area. (The indicator does not dissappear or stops working, as with setxkbmap.)

  • Does not screw up keymap on the lockscreen, preventing entering the right password if the wrong layout was chosen before locking (as does setxkbmap).

  • Does not modify the main key combinations like Ctrl-C, Ctrl-V: they still work with the same keys even in different layouts (being different from, well you get the idea, setxkbmap).

  • Honors all the Cinnamon layout mechanics, like the setting of either using the same layout for all windows or individual layout per-window. (Take a guess if setxkbmap does that?)


The installation instructions are on the Github.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f968673%2fhow-to-gracefully-change-keyboard-layout-from-command-line-setxkbmap-breaks-all%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The best solution currently is to use this external program (xkb-switch) that accepts command line arguments and script it into xbindkeys or something similar.



    Although unofficial, external, and written in a compilable language, it is actually pretty easy to install since it has almost no dependencies.



    https://github.com/ierton/xkb-switch



    $ xkb-switch --help

    Usage: xkb-switch -s ARG Sets current layout group to ARG
    xkb-switch -l|--list Displays all layout groups
    xkb-switch -h|--help Displays this message
    xkb-switch -v|--version Shows version number
    xkb-switch -w|--wait [-p] Waits for group change and exits
    xkb-switch -W Infinitely waits for group change
    xkb-switch -n|--next Switch to the next layout group
    xkb-switch [-p] Displays current layout group


    Use as:



    xkb-switch -s us
    xkb-switch -s de
    etc...


    This solution:




    • Works from command line.

    • Is fast, invocation of this program does not introduce any delay (as opposed to switching layout setxkbmap).

    • Correctly switches the built-in layout indicator in the tray icon area. (The indicator does not dissappear or stops working, as with setxkbmap.)

    • Does not screw up keymap on the lockscreen, preventing entering the right password if the wrong layout was chosen before locking (as does setxkbmap).

    • Does not modify the main key combinations like Ctrl-C, Ctrl-V: they still work with the same keys even in different layouts (being different from, well you get the idea, setxkbmap).

    • Honors all the Cinnamon layout mechanics, like the setting of either using the same layout for all windows or individual layout per-window. (Take a guess if setxkbmap does that?)


    The installation instructions are on the Github.






    share|improve this answer


























      0














      The best solution currently is to use this external program (xkb-switch) that accepts command line arguments and script it into xbindkeys or something similar.



      Although unofficial, external, and written in a compilable language, it is actually pretty easy to install since it has almost no dependencies.



      https://github.com/ierton/xkb-switch



      $ xkb-switch --help

      Usage: xkb-switch -s ARG Sets current layout group to ARG
      xkb-switch -l|--list Displays all layout groups
      xkb-switch -h|--help Displays this message
      xkb-switch -v|--version Shows version number
      xkb-switch -w|--wait [-p] Waits for group change and exits
      xkb-switch -W Infinitely waits for group change
      xkb-switch -n|--next Switch to the next layout group
      xkb-switch [-p] Displays current layout group


      Use as:



      xkb-switch -s us
      xkb-switch -s de
      etc...


      This solution:




      • Works from command line.

      • Is fast, invocation of this program does not introduce any delay (as opposed to switching layout setxkbmap).

      • Correctly switches the built-in layout indicator in the tray icon area. (The indicator does not dissappear or stops working, as with setxkbmap.)

      • Does not screw up keymap on the lockscreen, preventing entering the right password if the wrong layout was chosen before locking (as does setxkbmap).

      • Does not modify the main key combinations like Ctrl-C, Ctrl-V: they still work with the same keys even in different layouts (being different from, well you get the idea, setxkbmap).

      • Honors all the Cinnamon layout mechanics, like the setting of either using the same layout for all windows or individual layout per-window. (Take a guess if setxkbmap does that?)


      The installation instructions are on the Github.






      share|improve this answer
























        0












        0








        0






        The best solution currently is to use this external program (xkb-switch) that accepts command line arguments and script it into xbindkeys or something similar.



        Although unofficial, external, and written in a compilable language, it is actually pretty easy to install since it has almost no dependencies.



        https://github.com/ierton/xkb-switch



        $ xkb-switch --help

        Usage: xkb-switch -s ARG Sets current layout group to ARG
        xkb-switch -l|--list Displays all layout groups
        xkb-switch -h|--help Displays this message
        xkb-switch -v|--version Shows version number
        xkb-switch -w|--wait [-p] Waits for group change and exits
        xkb-switch -W Infinitely waits for group change
        xkb-switch -n|--next Switch to the next layout group
        xkb-switch [-p] Displays current layout group


        Use as:



        xkb-switch -s us
        xkb-switch -s de
        etc...


        This solution:




        • Works from command line.

        • Is fast, invocation of this program does not introduce any delay (as opposed to switching layout setxkbmap).

        • Correctly switches the built-in layout indicator in the tray icon area. (The indicator does not dissappear or stops working, as with setxkbmap.)

        • Does not screw up keymap on the lockscreen, preventing entering the right password if the wrong layout was chosen before locking (as does setxkbmap).

        • Does not modify the main key combinations like Ctrl-C, Ctrl-V: they still work with the same keys even in different layouts (being different from, well you get the idea, setxkbmap).

        • Honors all the Cinnamon layout mechanics, like the setting of either using the same layout for all windows or individual layout per-window. (Take a guess if setxkbmap does that?)


        The installation instructions are on the Github.






        share|improve this answer












        The best solution currently is to use this external program (xkb-switch) that accepts command line arguments and script it into xbindkeys or something similar.



        Although unofficial, external, and written in a compilable language, it is actually pretty easy to install since it has almost no dependencies.



        https://github.com/ierton/xkb-switch



        $ xkb-switch --help

        Usage: xkb-switch -s ARG Sets current layout group to ARG
        xkb-switch -l|--list Displays all layout groups
        xkb-switch -h|--help Displays this message
        xkb-switch -v|--version Shows version number
        xkb-switch -w|--wait [-p] Waits for group change and exits
        xkb-switch -W Infinitely waits for group change
        xkb-switch -n|--next Switch to the next layout group
        xkb-switch [-p] Displays current layout group


        Use as:



        xkb-switch -s us
        xkb-switch -s de
        etc...


        This solution:




        • Works from command line.

        • Is fast, invocation of this program does not introduce any delay (as opposed to switching layout setxkbmap).

        • Correctly switches the built-in layout indicator in the tray icon area. (The indicator does not dissappear or stops working, as with setxkbmap.)

        • Does not screw up keymap on the lockscreen, preventing entering the right password if the wrong layout was chosen before locking (as does setxkbmap).

        • Does not modify the main key combinations like Ctrl-C, Ctrl-V: they still work with the same keys even in different layouts (being different from, well you get the idea, setxkbmap).

        • Honors all the Cinnamon layout mechanics, like the setting of either using the same layout for all windows or individual layout per-window. (Take a guess if setxkbmap does that?)


        The installation instructions are on the Github.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 19 '18 at 21:27









        CrayCray

        1607




        1607






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f968673%2fhow-to-gracefully-change-keyboard-layout-from-command-line-setxkbmap-breaks-all%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Quarter-circle Tiles

            build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

            Mont Emei