How do I change keyboards from the command line? Unicorn Meta Zoo #1: Why another podcast? ...
Does a Draconic Bloodline sorcerer's doubled proficiency bonus for Charisma checks against dragons apply to all dragon types or only the chosen one?
How would you suggest I follow up with coworkers about our deadline that's today?
Why do people think Winterfell crypts is the safest place for women, children and old people?
Suing a Police Officer Instead of the Police Department
Marquee sign letters
Married in secret, can marital status in passport be changed at a later date?
Protagonist's race is hidden - should I reveal it?
What to do with someone that cheated their way though university and a PhD program?
Was Objective-C really a hindrance to Apple software development?
"Working on a knee"
Is it accepted to use working hours to read general interest books?
Putting Ant-Man on house arrest
Arriving in Atlanta after US Preclearance in Dublin. Will I go through TSA security in Atlanta to transfer to a connecting flight?
Does using the Inspiration rules for character defects encourage My Guy Syndrome?
RIP Packet Format
Getting AggregateResult variables from Execute Anonymous Window
What is the definining line between a helicopter and a drone a person can ride in?
Processing ADC conversion result: DMA vs Processor Registers
Like totally amazing interchangeable sister outfit accessory swapping or whatever
Did war bonds have better investment alternatives during WWII?
My admission is revoked after accepting the admission offer
Is there a possibility to generate a list dynamically in Latex?
Co-worker works way more than he should
Why does the Cisco show run command not show the full version, while the show version command does?
How do I change keyboards from the command line?
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraIs it possible to choose keyboard layout via terminal command?Is it possible to use a custom keyboard layout without sudo access? If so, how?How to initiate automatic execution of commands upon keyboard layout switch?How to disable input language switching in terminalSwitch to specific keyboard layout using Ctrl+Shift+NumHow to set keyboard switch with Ctrl+1, Ctrl+2, Ctrl+3 etcHow to change the abbreviations of layouts shown in keyboard layout indicator of GNOME panel?Cannot change keyboard layout after uninstalling UnityHow to switch between input-source modes through Terminal?How to specify in password input dialog the language always to be English?Switch to specific keyboard layout using Ctrl+Shift+NumHow to use the new Keyboard SwitcherGnome 3 keyboard layout rotationChange from qwerty to azerty in command lineEnabling SIL phonetic Biblical Hebrew keyboardHow to make a Hebrew-English keyboard layout combo behave like in Windows?How to change command-line keyboard shortcuts?Switch keyboard layouts with i3Russian keyboard doesn't workHow do I differentiate between different keyboards?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
How I change keyboard layouts from the command-line? For example, I want to switch from English to Hebrew. I'm able to do it from lightdm with the little icon in the corner of my screen.
keyboard internationalization
add a comment |
How I change keyboard layouts from the command-line? For example, I want to switch from English to Hebrew. I'm able to do it from lightdm with the little icon in the corner of my screen.
keyboard internationalization
add a comment |
How I change keyboard layouts from the command-line? For example, I want to switch from English to Hebrew. I'm able to do it from lightdm with the little icon in the corner of my screen.
keyboard internationalization
How I change keyboard layouts from the command-line? For example, I want to switch from English to Hebrew. I'm able to do it from lightdm with the little icon in the corner of my screen.
keyboard internationalization
keyboard internationalization
asked Oct 30 '12 at 13:05
EyalEyal
5381511
5381511
add a comment |
add a comment |
8 Answers
8
active
oldest
votes
From terminal
English to Hebrew and vise versa with Alt + Shift
setxkbmap -option grp:alt_shift_toggle us,il
You can see all locale alias with this command
cat /etc/locale.alias
More info about setxkbmap in manual
man setxkbmap
Information in how to set it on boot: wiki.gentoo.org/wiki/Keyboard_layout_switching
– Adriano P
Apr 20 '17 at 17:36
add a comment |
You can find all the different keymaps in the following locations:
/usr/share/keymaps/i386/
/usr/share/kbd/keymaps/i386/
/usr/share/X11/xkb/symbols/
To change the keyboard layout (e.g. to Spanish) in the Linux command
line, type the following command:
loadkeys es
For X:
setxkbmap es
To make these changes system wide, assuming you’re using Ubuntu, you
can use the following:
sudo dpkg-reconfigure console-setup
This has effect on tty1, tty2, etc, but no effect in X. I want to do it in X, the same way that the keyboard switcher in lightdm works.
– Eyal
Oct 30 '12 at 13:21
I added a command in the answer, was this what you were looking for?
– Dr_Bunsen
Oct 30 '12 at 13:25
YES! Thanks. Also, can you update your answer to mention loadkeys, spelled with an 's'?
– Eyal
Oct 30 '12 at 13:27
2
yep I will, and no thanks. Just mark as solved so everyone knows.
– Dr_Bunsen
Oct 30 '12 at 13:28
for redhat users, following are the valuable pieces:/usr/share/X11/xkb/symbols/
andsetxkbmap es
– Peter Butkovic
Nov 18 '15 at 11:35
|
show 1 more comment
Ubuntu 13.10 or Later
This works better then setxkbmap with Gnome/Unity keyboard layout indicator.
gsettings set org.gnome.desktop.input-sources current 0
0 is the layout index (0 default or top layout). Layouts indexed starting from 0.
For easy use, create an alias.
2
This answer is superior because it actually changes the indicator. Just what I've been looking for.
– Ainar-G
Apr 27 '17 at 20:50
1
thanks. used your answer also here: askubuntu.com/a/984981/6193
– Alexey
Dec 10 '17 at 15:11
3
This doens't work on GNOME 3.26. It says "This key is deprecated and ignored".
– hugomg
Mar 3 '18 at 14:21
@hugomg, right now I don't have access yet to newer gnome. but you may try usingdconf-editor
tool and check/org/gnome/desktop/
. they may just rename it.
– user.dz
Mar 3 '18 at 15:42
add a comment |
setxkbmap us,il -option "lv3:ralt_alt,grp:alt_shift_toggle"
this command enable you toggle between English and Hebrew only through by right alt+shift and rescue you from left alt+shift.
add a comment |
There seems to be no standard CLI tool, but xkb-switch is a small open-source tool to do the job. Just tested it with Ubuntu 16.04.4 LTS and it works flawelessly.
$ xkb-switch # display current group
ua
$ xkb-switch -l # list groups
us
ua
$ xkb-switch -s us # switch to a named group
$
This looks better than the other solutions because setxkbmap <name>
ruins all options, and setxkbmap -layout <name>
, while it preserves the options, it still fails to change the taskbar indicator nor the grp_led
if set.
Caveat
If your ~/.config/kxkbrc
uses LayoutLoopCount
(e.g. it is set to less than the total number of layouts listed in LayoutList
), like this:
LayoutList=us,ua,th,de
LayoutLoopCount=2
Options=grp_led:scroll,grp:rwin_switch,compose:menu,lv3:ralt_switch,
nbsp:level2,grp:rctrl_toggle,misc:typo
then xkb-switch
would only let you switch between the layouts in current group.
Invoke at screen lock
I noticed your comment:
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
This was precisely my goal, so here's the answer:
To do that, you only need wrap it into a script hooking to dbus-monitor
like discussed here.
add a comment |
Using gsettings in 18.04+ with Gnome, you can both add add keyboard layouts and switch between them from the command line or from the keyboard layout switcher on the desktop.
1.Present keyboard layouts and options:
$ gsettings list-recursively org.gnome.desktop.input-sources
org.gnome.desktop.input-sources show-all-sources false
org.gnome.desktop.input-sources xkb-options ['terminate:ctrl_alt_bksp']
org.gnome.desktop.input-sources per-window false
org.gnome.desktop.input-sources current uint32 1
org.gnome.desktop.input-sources mru-sources @a(ss) []
org.gnome.desktop.input-sources sources [('xkb', 'es'), ('xkb', 'no')]
2.Adding keyboard layouts:
$ gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'no'),('xkb','gr')]"
$ gsettings get org.gnome.desktop.input-sources sources
[('xkb', 'es'), ('xkb', 'no'), ('xkb', 'gr')]
3.Changing the current keyboard layout from the command line:
$ gsettings set org.gnome.desktop.input-sources current 1
As we now have 3 different languages, we have three choices from 0 to 2, with 1 being Spanish, 2 being Norwegian and 3 being Greek. Thus, setting current to 1 above makes Norwegian the current keyboard layout.
4.Listing all possible keyboard layouts:
cat //usr/share/X11/xkb/rules/base.lst
5.Changing the keyboard layout with a keyboard shortcut:
A keyboard shortcut is preconfigured for changing the keyboard layout. The present shortcut:
$ gsettings get org.gnome.desktop.wm.keybindings switch-input-source
['<Super>space']
A new shortcut can be set by using gsetting set, but take care not to use a shortcut that is already in use. To list all shortcuts in use:
$ gsettings list-recursively org.gnome.desktop.wm.keybindings
org.gnome.desktop.wm.keybindings cycle-windows-backward ['<Shift><Alt>Escape']
org.gnome.desktop.wm.keybindings minimize ['<Super>h']
org.gnome.desktop.wm.keybindings move-to-workspace-7 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-8 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-9 @as []
org.gnome.desktop.wm.keybindings move-to-monitor-left ['<Super><Shift>Left']
...
This is the most comprehensive answer, kudos for this.
– Julien Chappuis
Oct 14 '18 at 10:45
add a comment |
For Ubuntu 18.04 + Gnome the other answers did not work for me, but this did:
gdbus call --session --dest org.gnome.Shell
--object-path /org/gnome/Shell
--method org.gnome.Shell.Eval
"imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()"
The argument in "inputSources[0]" is the index of the keyboard layout, the same as for gsettings solution.
Found it on linux StackExchange.
add a comment |
Just out of curiosity, why would you do that ? Why would you open a terminal and they type a command to switch your keyboard layout when you can do so by a simple keyboard shortcut ! Assuming you use Ubuntu , it goes as Windows
+ Space
2
This appears to be more of a comment and less of an answer.
– WinEunuuchs2Unix
Feb 26 '17 at 15:48
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
– Eyal
Mar 8 '17 at 19:33
also it is useful for making custom keyboard-shortcuts
– Vassilis
Oct 13 '17 at 11:24
This does not work in Ubuntu 16.04 on a virtualbox.
– Juha Untinen
Feb 15 '18 at 9:48
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f209597%2fhow-do-i-change-keyboards-from-the-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
From terminal
English to Hebrew and vise versa with Alt + Shift
setxkbmap -option grp:alt_shift_toggle us,il
You can see all locale alias with this command
cat /etc/locale.alias
More info about setxkbmap in manual
man setxkbmap
Information in how to set it on boot: wiki.gentoo.org/wiki/Keyboard_layout_switching
– Adriano P
Apr 20 '17 at 17:36
add a comment |
From terminal
English to Hebrew and vise versa with Alt + Shift
setxkbmap -option grp:alt_shift_toggle us,il
You can see all locale alias with this command
cat /etc/locale.alias
More info about setxkbmap in manual
man setxkbmap
Information in how to set it on boot: wiki.gentoo.org/wiki/Keyboard_layout_switching
– Adriano P
Apr 20 '17 at 17:36
add a comment |
From terminal
English to Hebrew and vise versa with Alt + Shift
setxkbmap -option grp:alt_shift_toggle us,il
You can see all locale alias with this command
cat /etc/locale.alias
More info about setxkbmap in manual
man setxkbmap
From terminal
English to Hebrew and vise versa with Alt + Shift
setxkbmap -option grp:alt_shift_toggle us,il
You can see all locale alias with this command
cat /etc/locale.alias
More info about setxkbmap in manual
man setxkbmap
answered Oct 30 '12 at 14:29
NickTuxNickTux
14.1k54565
14.1k54565
Information in how to set it on boot: wiki.gentoo.org/wiki/Keyboard_layout_switching
– Adriano P
Apr 20 '17 at 17:36
add a comment |
Information in how to set it on boot: wiki.gentoo.org/wiki/Keyboard_layout_switching
– Adriano P
Apr 20 '17 at 17:36
Information in how to set it on boot: wiki.gentoo.org/wiki/Keyboard_layout_switching
– Adriano P
Apr 20 '17 at 17:36
Information in how to set it on boot: wiki.gentoo.org/wiki/Keyboard_layout_switching
– Adriano P
Apr 20 '17 at 17:36
add a comment |
You can find all the different keymaps in the following locations:
/usr/share/keymaps/i386/
/usr/share/kbd/keymaps/i386/
/usr/share/X11/xkb/symbols/
To change the keyboard layout (e.g. to Spanish) in the Linux command
line, type the following command:
loadkeys es
For X:
setxkbmap es
To make these changes system wide, assuming you’re using Ubuntu, you
can use the following:
sudo dpkg-reconfigure console-setup
This has effect on tty1, tty2, etc, but no effect in X. I want to do it in X, the same way that the keyboard switcher in lightdm works.
– Eyal
Oct 30 '12 at 13:21
I added a command in the answer, was this what you were looking for?
– Dr_Bunsen
Oct 30 '12 at 13:25
YES! Thanks. Also, can you update your answer to mention loadkeys, spelled with an 's'?
– Eyal
Oct 30 '12 at 13:27
2
yep I will, and no thanks. Just mark as solved so everyone knows.
– Dr_Bunsen
Oct 30 '12 at 13:28
for redhat users, following are the valuable pieces:/usr/share/X11/xkb/symbols/
andsetxkbmap es
– Peter Butkovic
Nov 18 '15 at 11:35
|
show 1 more comment
You can find all the different keymaps in the following locations:
/usr/share/keymaps/i386/
/usr/share/kbd/keymaps/i386/
/usr/share/X11/xkb/symbols/
To change the keyboard layout (e.g. to Spanish) in the Linux command
line, type the following command:
loadkeys es
For X:
setxkbmap es
To make these changes system wide, assuming you’re using Ubuntu, you
can use the following:
sudo dpkg-reconfigure console-setup
This has effect on tty1, tty2, etc, but no effect in X. I want to do it in X, the same way that the keyboard switcher in lightdm works.
– Eyal
Oct 30 '12 at 13:21
I added a command in the answer, was this what you were looking for?
– Dr_Bunsen
Oct 30 '12 at 13:25
YES! Thanks. Also, can you update your answer to mention loadkeys, spelled with an 's'?
– Eyal
Oct 30 '12 at 13:27
2
yep I will, and no thanks. Just mark as solved so everyone knows.
– Dr_Bunsen
Oct 30 '12 at 13:28
for redhat users, following are the valuable pieces:/usr/share/X11/xkb/symbols/
andsetxkbmap es
– Peter Butkovic
Nov 18 '15 at 11:35
|
show 1 more comment
You can find all the different keymaps in the following locations:
/usr/share/keymaps/i386/
/usr/share/kbd/keymaps/i386/
/usr/share/X11/xkb/symbols/
To change the keyboard layout (e.g. to Spanish) in the Linux command
line, type the following command:
loadkeys es
For X:
setxkbmap es
To make these changes system wide, assuming you’re using Ubuntu, you
can use the following:
sudo dpkg-reconfigure console-setup
You can find all the different keymaps in the following locations:
/usr/share/keymaps/i386/
/usr/share/kbd/keymaps/i386/
/usr/share/X11/xkb/symbols/
To change the keyboard layout (e.g. to Spanish) in the Linux command
line, type the following command:
loadkeys es
For X:
setxkbmap es
To make these changes system wide, assuming you’re using Ubuntu, you
can use the following:
sudo dpkg-reconfigure console-setup
edited Jul 3 '15 at 19:53
sebix
16315
16315
answered Oct 30 '12 at 13:09
Dr_BunsenDr_Bunsen
2,60742134
2,60742134
This has effect on tty1, tty2, etc, but no effect in X. I want to do it in X, the same way that the keyboard switcher in lightdm works.
– Eyal
Oct 30 '12 at 13:21
I added a command in the answer, was this what you were looking for?
– Dr_Bunsen
Oct 30 '12 at 13:25
YES! Thanks. Also, can you update your answer to mention loadkeys, spelled with an 's'?
– Eyal
Oct 30 '12 at 13:27
2
yep I will, and no thanks. Just mark as solved so everyone knows.
– Dr_Bunsen
Oct 30 '12 at 13:28
for redhat users, following are the valuable pieces:/usr/share/X11/xkb/symbols/
andsetxkbmap es
– Peter Butkovic
Nov 18 '15 at 11:35
|
show 1 more comment
This has effect on tty1, tty2, etc, but no effect in X. I want to do it in X, the same way that the keyboard switcher in lightdm works.
– Eyal
Oct 30 '12 at 13:21
I added a command in the answer, was this what you were looking for?
– Dr_Bunsen
Oct 30 '12 at 13:25
YES! Thanks. Also, can you update your answer to mention loadkeys, spelled with an 's'?
– Eyal
Oct 30 '12 at 13:27
2
yep I will, and no thanks. Just mark as solved so everyone knows.
– Dr_Bunsen
Oct 30 '12 at 13:28
for redhat users, following are the valuable pieces:/usr/share/X11/xkb/symbols/
andsetxkbmap es
– Peter Butkovic
Nov 18 '15 at 11:35
This has effect on tty1, tty2, etc, but no effect in X. I want to do it in X, the same way that the keyboard switcher in lightdm works.
– Eyal
Oct 30 '12 at 13:21
This has effect on tty1, tty2, etc, but no effect in X. I want to do it in X, the same way that the keyboard switcher in lightdm works.
– Eyal
Oct 30 '12 at 13:21
I added a command in the answer, was this what you were looking for?
– Dr_Bunsen
Oct 30 '12 at 13:25
I added a command in the answer, was this what you were looking for?
– Dr_Bunsen
Oct 30 '12 at 13:25
YES! Thanks. Also, can you update your answer to mention loadkeys, spelled with an 's'?
– Eyal
Oct 30 '12 at 13:27
YES! Thanks. Also, can you update your answer to mention loadkeys, spelled with an 's'?
– Eyal
Oct 30 '12 at 13:27
2
2
yep I will, and no thanks. Just mark as solved so everyone knows.
– Dr_Bunsen
Oct 30 '12 at 13:28
yep I will, and no thanks. Just mark as solved so everyone knows.
– Dr_Bunsen
Oct 30 '12 at 13:28
for redhat users, following are the valuable pieces:
/usr/share/X11/xkb/symbols/
and setxkbmap es
– Peter Butkovic
Nov 18 '15 at 11:35
for redhat users, following are the valuable pieces:
/usr/share/X11/xkb/symbols/
and setxkbmap es
– Peter Butkovic
Nov 18 '15 at 11:35
|
show 1 more comment
Ubuntu 13.10 or Later
This works better then setxkbmap with Gnome/Unity keyboard layout indicator.
gsettings set org.gnome.desktop.input-sources current 0
0 is the layout index (0 default or top layout). Layouts indexed starting from 0.
For easy use, create an alias.
2
This answer is superior because it actually changes the indicator. Just what I've been looking for.
– Ainar-G
Apr 27 '17 at 20:50
1
thanks. used your answer also here: askubuntu.com/a/984981/6193
– Alexey
Dec 10 '17 at 15:11
3
This doens't work on GNOME 3.26. It says "This key is deprecated and ignored".
– hugomg
Mar 3 '18 at 14:21
@hugomg, right now I don't have access yet to newer gnome. but you may try usingdconf-editor
tool and check/org/gnome/desktop/
. they may just rename it.
– user.dz
Mar 3 '18 at 15:42
add a comment |
Ubuntu 13.10 or Later
This works better then setxkbmap with Gnome/Unity keyboard layout indicator.
gsettings set org.gnome.desktop.input-sources current 0
0 is the layout index (0 default or top layout). Layouts indexed starting from 0.
For easy use, create an alias.
2
This answer is superior because it actually changes the indicator. Just what I've been looking for.
– Ainar-G
Apr 27 '17 at 20:50
1
thanks. used your answer also here: askubuntu.com/a/984981/6193
– Alexey
Dec 10 '17 at 15:11
3
This doens't work on GNOME 3.26. It says "This key is deprecated and ignored".
– hugomg
Mar 3 '18 at 14:21
@hugomg, right now I don't have access yet to newer gnome. but you may try usingdconf-editor
tool and check/org/gnome/desktop/
. they may just rename it.
– user.dz
Mar 3 '18 at 15:42
add a comment |
Ubuntu 13.10 or Later
This works better then setxkbmap with Gnome/Unity keyboard layout indicator.
gsettings set org.gnome.desktop.input-sources current 0
0 is the layout index (0 default or top layout). Layouts indexed starting from 0.
For easy use, create an alias.
Ubuntu 13.10 or Later
This works better then setxkbmap with Gnome/Unity keyboard layout indicator.
gsettings set org.gnome.desktop.input-sources current 0
0 is the layout index (0 default or top layout). Layouts indexed starting from 0.
For easy use, create an alias.
edited Feb 1 '14 at 15:45
answered Feb 1 '14 at 13:45
user.dzuser.dz
35.3k1198179
35.3k1198179
2
This answer is superior because it actually changes the indicator. Just what I've been looking for.
– Ainar-G
Apr 27 '17 at 20:50
1
thanks. used your answer also here: askubuntu.com/a/984981/6193
– Alexey
Dec 10 '17 at 15:11
3
This doens't work on GNOME 3.26. It says "This key is deprecated and ignored".
– hugomg
Mar 3 '18 at 14:21
@hugomg, right now I don't have access yet to newer gnome. but you may try usingdconf-editor
tool and check/org/gnome/desktop/
. they may just rename it.
– user.dz
Mar 3 '18 at 15:42
add a comment |
2
This answer is superior because it actually changes the indicator. Just what I've been looking for.
– Ainar-G
Apr 27 '17 at 20:50
1
thanks. used your answer also here: askubuntu.com/a/984981/6193
– Alexey
Dec 10 '17 at 15:11
3
This doens't work on GNOME 3.26. It says "This key is deprecated and ignored".
– hugomg
Mar 3 '18 at 14:21
@hugomg, right now I don't have access yet to newer gnome. but you may try usingdconf-editor
tool and check/org/gnome/desktop/
. they may just rename it.
– user.dz
Mar 3 '18 at 15:42
2
2
This answer is superior because it actually changes the indicator. Just what I've been looking for.
– Ainar-G
Apr 27 '17 at 20:50
This answer is superior because it actually changes the indicator. Just what I've been looking for.
– Ainar-G
Apr 27 '17 at 20:50
1
1
thanks. used your answer also here: askubuntu.com/a/984981/6193
– Alexey
Dec 10 '17 at 15:11
thanks. used your answer also here: askubuntu.com/a/984981/6193
– Alexey
Dec 10 '17 at 15:11
3
3
This doens't work on GNOME 3.26. It says "This key is deprecated and ignored".
– hugomg
Mar 3 '18 at 14:21
This doens't work on GNOME 3.26. It says "This key is deprecated and ignored".
– hugomg
Mar 3 '18 at 14:21
@hugomg, right now I don't have access yet to newer gnome. but you may try using
dconf-editor
tool and check /org/gnome/desktop/
. they may just rename it.– user.dz
Mar 3 '18 at 15:42
@hugomg, right now I don't have access yet to newer gnome. but you may try using
dconf-editor
tool and check /org/gnome/desktop/
. they may just rename it.– user.dz
Mar 3 '18 at 15:42
add a comment |
setxkbmap us,il -option "lv3:ralt_alt,grp:alt_shift_toggle"
this command enable you toggle between English and Hebrew only through by right alt+shift and rescue you from left alt+shift.
add a comment |
setxkbmap us,il -option "lv3:ralt_alt,grp:alt_shift_toggle"
this command enable you toggle between English and Hebrew only through by right alt+shift and rescue you from left alt+shift.
add a comment |
setxkbmap us,il -option "lv3:ralt_alt,grp:alt_shift_toggle"
this command enable you toggle between English and Hebrew only through by right alt+shift and rescue you from left alt+shift.
setxkbmap us,il -option "lv3:ralt_alt,grp:alt_shift_toggle"
this command enable you toggle between English and Hebrew only through by right alt+shift and rescue you from left alt+shift.
edited Feb 3 '14 at 14:04
Olli
7,05713040
7,05713040
answered Feb 3 '14 at 13:44
ansar313ansar313
13418
13418
add a comment |
add a comment |
There seems to be no standard CLI tool, but xkb-switch is a small open-source tool to do the job. Just tested it with Ubuntu 16.04.4 LTS and it works flawelessly.
$ xkb-switch # display current group
ua
$ xkb-switch -l # list groups
us
ua
$ xkb-switch -s us # switch to a named group
$
This looks better than the other solutions because setxkbmap <name>
ruins all options, and setxkbmap -layout <name>
, while it preserves the options, it still fails to change the taskbar indicator nor the grp_led
if set.
Caveat
If your ~/.config/kxkbrc
uses LayoutLoopCount
(e.g. it is set to less than the total number of layouts listed in LayoutList
), like this:
LayoutList=us,ua,th,de
LayoutLoopCount=2
Options=grp_led:scroll,grp:rwin_switch,compose:menu,lv3:ralt_switch,
nbsp:level2,grp:rctrl_toggle,misc:typo
then xkb-switch
would only let you switch between the layouts in current group.
Invoke at screen lock
I noticed your comment:
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
This was precisely my goal, so here's the answer:
To do that, you only need wrap it into a script hooking to dbus-monitor
like discussed here.
add a comment |
There seems to be no standard CLI tool, but xkb-switch is a small open-source tool to do the job. Just tested it with Ubuntu 16.04.4 LTS and it works flawelessly.
$ xkb-switch # display current group
ua
$ xkb-switch -l # list groups
us
ua
$ xkb-switch -s us # switch to a named group
$
This looks better than the other solutions because setxkbmap <name>
ruins all options, and setxkbmap -layout <name>
, while it preserves the options, it still fails to change the taskbar indicator nor the grp_led
if set.
Caveat
If your ~/.config/kxkbrc
uses LayoutLoopCount
(e.g. it is set to less than the total number of layouts listed in LayoutList
), like this:
LayoutList=us,ua,th,de
LayoutLoopCount=2
Options=grp_led:scroll,grp:rwin_switch,compose:menu,lv3:ralt_switch,
nbsp:level2,grp:rctrl_toggle,misc:typo
then xkb-switch
would only let you switch between the layouts in current group.
Invoke at screen lock
I noticed your comment:
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
This was precisely my goal, so here's the answer:
To do that, you only need wrap it into a script hooking to dbus-monitor
like discussed here.
add a comment |
There seems to be no standard CLI tool, but xkb-switch is a small open-source tool to do the job. Just tested it with Ubuntu 16.04.4 LTS and it works flawelessly.
$ xkb-switch # display current group
ua
$ xkb-switch -l # list groups
us
ua
$ xkb-switch -s us # switch to a named group
$
This looks better than the other solutions because setxkbmap <name>
ruins all options, and setxkbmap -layout <name>
, while it preserves the options, it still fails to change the taskbar indicator nor the grp_led
if set.
Caveat
If your ~/.config/kxkbrc
uses LayoutLoopCount
(e.g. it is set to less than the total number of layouts listed in LayoutList
), like this:
LayoutList=us,ua,th,de
LayoutLoopCount=2
Options=grp_led:scroll,grp:rwin_switch,compose:menu,lv3:ralt_switch,
nbsp:level2,grp:rctrl_toggle,misc:typo
then xkb-switch
would only let you switch between the layouts in current group.
Invoke at screen lock
I noticed your comment:
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
This was precisely my goal, so here's the answer:
To do that, you only need wrap it into a script hooking to dbus-monitor
like discussed here.
There seems to be no standard CLI tool, but xkb-switch is a small open-source tool to do the job. Just tested it with Ubuntu 16.04.4 LTS and it works flawelessly.
$ xkb-switch # display current group
ua
$ xkb-switch -l # list groups
us
ua
$ xkb-switch -s us # switch to a named group
$
This looks better than the other solutions because setxkbmap <name>
ruins all options, and setxkbmap -layout <name>
, while it preserves the options, it still fails to change the taskbar indicator nor the grp_led
if set.
Caveat
If your ~/.config/kxkbrc
uses LayoutLoopCount
(e.g. it is set to less than the total number of layouts listed in LayoutList
), like this:
LayoutList=us,ua,th,de
LayoutLoopCount=2
Options=grp_led:scroll,grp:rwin_switch,compose:menu,lv3:ralt_switch,
nbsp:level2,grp:rctrl_toggle,misc:typo
then xkb-switch
would only let you switch between the layouts in current group.
Invoke at screen lock
I noticed your comment:
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
This was precisely my goal, so here's the answer:
To do that, you only need wrap it into a script hooking to dbus-monitor
like discussed here.
answered Mar 20 '18 at 11:02
bytebusterbytebuster
157129
157129
add a comment |
add a comment |
Using gsettings in 18.04+ with Gnome, you can both add add keyboard layouts and switch between them from the command line or from the keyboard layout switcher on the desktop.
1.Present keyboard layouts and options:
$ gsettings list-recursively org.gnome.desktop.input-sources
org.gnome.desktop.input-sources show-all-sources false
org.gnome.desktop.input-sources xkb-options ['terminate:ctrl_alt_bksp']
org.gnome.desktop.input-sources per-window false
org.gnome.desktop.input-sources current uint32 1
org.gnome.desktop.input-sources mru-sources @a(ss) []
org.gnome.desktop.input-sources sources [('xkb', 'es'), ('xkb', 'no')]
2.Adding keyboard layouts:
$ gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'no'),('xkb','gr')]"
$ gsettings get org.gnome.desktop.input-sources sources
[('xkb', 'es'), ('xkb', 'no'), ('xkb', 'gr')]
3.Changing the current keyboard layout from the command line:
$ gsettings set org.gnome.desktop.input-sources current 1
As we now have 3 different languages, we have three choices from 0 to 2, with 1 being Spanish, 2 being Norwegian and 3 being Greek. Thus, setting current to 1 above makes Norwegian the current keyboard layout.
4.Listing all possible keyboard layouts:
cat //usr/share/X11/xkb/rules/base.lst
5.Changing the keyboard layout with a keyboard shortcut:
A keyboard shortcut is preconfigured for changing the keyboard layout. The present shortcut:
$ gsettings get org.gnome.desktop.wm.keybindings switch-input-source
['<Super>space']
A new shortcut can be set by using gsetting set, but take care not to use a shortcut that is already in use. To list all shortcuts in use:
$ gsettings list-recursively org.gnome.desktop.wm.keybindings
org.gnome.desktop.wm.keybindings cycle-windows-backward ['<Shift><Alt>Escape']
org.gnome.desktop.wm.keybindings minimize ['<Super>h']
org.gnome.desktop.wm.keybindings move-to-workspace-7 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-8 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-9 @as []
org.gnome.desktop.wm.keybindings move-to-monitor-left ['<Super><Shift>Left']
...
This is the most comprehensive answer, kudos for this.
– Julien Chappuis
Oct 14 '18 at 10:45
add a comment |
Using gsettings in 18.04+ with Gnome, you can both add add keyboard layouts and switch between them from the command line or from the keyboard layout switcher on the desktop.
1.Present keyboard layouts and options:
$ gsettings list-recursively org.gnome.desktop.input-sources
org.gnome.desktop.input-sources show-all-sources false
org.gnome.desktop.input-sources xkb-options ['terminate:ctrl_alt_bksp']
org.gnome.desktop.input-sources per-window false
org.gnome.desktop.input-sources current uint32 1
org.gnome.desktop.input-sources mru-sources @a(ss) []
org.gnome.desktop.input-sources sources [('xkb', 'es'), ('xkb', 'no')]
2.Adding keyboard layouts:
$ gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'no'),('xkb','gr')]"
$ gsettings get org.gnome.desktop.input-sources sources
[('xkb', 'es'), ('xkb', 'no'), ('xkb', 'gr')]
3.Changing the current keyboard layout from the command line:
$ gsettings set org.gnome.desktop.input-sources current 1
As we now have 3 different languages, we have three choices from 0 to 2, with 1 being Spanish, 2 being Norwegian and 3 being Greek. Thus, setting current to 1 above makes Norwegian the current keyboard layout.
4.Listing all possible keyboard layouts:
cat //usr/share/X11/xkb/rules/base.lst
5.Changing the keyboard layout with a keyboard shortcut:
A keyboard shortcut is preconfigured for changing the keyboard layout. The present shortcut:
$ gsettings get org.gnome.desktop.wm.keybindings switch-input-source
['<Super>space']
A new shortcut can be set by using gsetting set, but take care not to use a shortcut that is already in use. To list all shortcuts in use:
$ gsettings list-recursively org.gnome.desktop.wm.keybindings
org.gnome.desktop.wm.keybindings cycle-windows-backward ['<Shift><Alt>Escape']
org.gnome.desktop.wm.keybindings minimize ['<Super>h']
org.gnome.desktop.wm.keybindings move-to-workspace-7 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-8 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-9 @as []
org.gnome.desktop.wm.keybindings move-to-monitor-left ['<Super><Shift>Left']
...
This is the most comprehensive answer, kudos for this.
– Julien Chappuis
Oct 14 '18 at 10:45
add a comment |
Using gsettings in 18.04+ with Gnome, you can both add add keyboard layouts and switch between them from the command line or from the keyboard layout switcher on the desktop.
1.Present keyboard layouts and options:
$ gsettings list-recursively org.gnome.desktop.input-sources
org.gnome.desktop.input-sources show-all-sources false
org.gnome.desktop.input-sources xkb-options ['terminate:ctrl_alt_bksp']
org.gnome.desktop.input-sources per-window false
org.gnome.desktop.input-sources current uint32 1
org.gnome.desktop.input-sources mru-sources @a(ss) []
org.gnome.desktop.input-sources sources [('xkb', 'es'), ('xkb', 'no')]
2.Adding keyboard layouts:
$ gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'no'),('xkb','gr')]"
$ gsettings get org.gnome.desktop.input-sources sources
[('xkb', 'es'), ('xkb', 'no'), ('xkb', 'gr')]
3.Changing the current keyboard layout from the command line:
$ gsettings set org.gnome.desktop.input-sources current 1
As we now have 3 different languages, we have three choices from 0 to 2, with 1 being Spanish, 2 being Norwegian and 3 being Greek. Thus, setting current to 1 above makes Norwegian the current keyboard layout.
4.Listing all possible keyboard layouts:
cat //usr/share/X11/xkb/rules/base.lst
5.Changing the keyboard layout with a keyboard shortcut:
A keyboard shortcut is preconfigured for changing the keyboard layout. The present shortcut:
$ gsettings get org.gnome.desktop.wm.keybindings switch-input-source
['<Super>space']
A new shortcut can be set by using gsetting set, but take care not to use a shortcut that is already in use. To list all shortcuts in use:
$ gsettings list-recursively org.gnome.desktop.wm.keybindings
org.gnome.desktop.wm.keybindings cycle-windows-backward ['<Shift><Alt>Escape']
org.gnome.desktop.wm.keybindings minimize ['<Super>h']
org.gnome.desktop.wm.keybindings move-to-workspace-7 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-8 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-9 @as []
org.gnome.desktop.wm.keybindings move-to-monitor-left ['<Super><Shift>Left']
...
Using gsettings in 18.04+ with Gnome, you can both add add keyboard layouts and switch between them from the command line or from the keyboard layout switcher on the desktop.
1.Present keyboard layouts and options:
$ gsettings list-recursively org.gnome.desktop.input-sources
org.gnome.desktop.input-sources show-all-sources false
org.gnome.desktop.input-sources xkb-options ['terminate:ctrl_alt_bksp']
org.gnome.desktop.input-sources per-window false
org.gnome.desktop.input-sources current uint32 1
org.gnome.desktop.input-sources mru-sources @a(ss) []
org.gnome.desktop.input-sources sources [('xkb', 'es'), ('xkb', 'no')]
2.Adding keyboard layouts:
$ gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us'), ('xkb', 'no'),('xkb','gr')]"
$ gsettings get org.gnome.desktop.input-sources sources
[('xkb', 'es'), ('xkb', 'no'), ('xkb', 'gr')]
3.Changing the current keyboard layout from the command line:
$ gsettings set org.gnome.desktop.input-sources current 1
As we now have 3 different languages, we have three choices from 0 to 2, with 1 being Spanish, 2 being Norwegian and 3 being Greek. Thus, setting current to 1 above makes Norwegian the current keyboard layout.
4.Listing all possible keyboard layouts:
cat //usr/share/X11/xkb/rules/base.lst
5.Changing the keyboard layout with a keyboard shortcut:
A keyboard shortcut is preconfigured for changing the keyboard layout. The present shortcut:
$ gsettings get org.gnome.desktop.wm.keybindings switch-input-source
['<Super>space']
A new shortcut can be set by using gsetting set, but take care not to use a shortcut that is already in use. To list all shortcuts in use:
$ gsettings list-recursively org.gnome.desktop.wm.keybindings
org.gnome.desktop.wm.keybindings cycle-windows-backward ['<Shift><Alt>Escape']
org.gnome.desktop.wm.keybindings minimize ['<Super>h']
org.gnome.desktop.wm.keybindings move-to-workspace-7 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-8 @as []
org.gnome.desktop.wm.keybindings move-to-workspace-9 @as []
org.gnome.desktop.wm.keybindings move-to-monitor-left ['<Super><Shift>Left']
...
edited May 8 '18 at 7:55
answered May 8 '18 at 7:40
ElToro1966ElToro1966
223211
223211
This is the most comprehensive answer, kudos for this.
– Julien Chappuis
Oct 14 '18 at 10:45
add a comment |
This is the most comprehensive answer, kudos for this.
– Julien Chappuis
Oct 14 '18 at 10:45
This is the most comprehensive answer, kudos for this.
– Julien Chappuis
Oct 14 '18 at 10:45
This is the most comprehensive answer, kudos for this.
– Julien Chappuis
Oct 14 '18 at 10:45
add a comment |
For Ubuntu 18.04 + Gnome the other answers did not work for me, but this did:
gdbus call --session --dest org.gnome.Shell
--object-path /org/gnome/Shell
--method org.gnome.Shell.Eval
"imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()"
The argument in "inputSources[0]" is the index of the keyboard layout, the same as for gsettings solution.
Found it on linux StackExchange.
add a comment |
For Ubuntu 18.04 + Gnome the other answers did not work for me, but this did:
gdbus call --session --dest org.gnome.Shell
--object-path /org/gnome/Shell
--method org.gnome.Shell.Eval
"imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()"
The argument in "inputSources[0]" is the index of the keyboard layout, the same as for gsettings solution.
Found it on linux StackExchange.
add a comment |
For Ubuntu 18.04 + Gnome the other answers did not work for me, but this did:
gdbus call --session --dest org.gnome.Shell
--object-path /org/gnome/Shell
--method org.gnome.Shell.Eval
"imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()"
The argument in "inputSources[0]" is the index of the keyboard layout, the same as for gsettings solution.
Found it on linux StackExchange.
For Ubuntu 18.04 + Gnome the other answers did not work for me, but this did:
gdbus call --session --dest org.gnome.Shell
--object-path /org/gnome/Shell
--method org.gnome.Shell.Eval
"imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()"
The argument in "inputSources[0]" is the index of the keyboard layout, the same as for gsettings solution.
Found it on linux StackExchange.
answered 10 hours ago
1mi1mi
1415
1415
add a comment |
add a comment |
Just out of curiosity, why would you do that ? Why would you open a terminal and they type a command to switch your keyboard layout when you can do so by a simple keyboard shortcut ! Assuming you use Ubuntu , it goes as Windows
+ Space
2
This appears to be more of a comment and less of an answer.
– WinEunuuchs2Unix
Feb 26 '17 at 15:48
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
– Eyal
Mar 8 '17 at 19:33
also it is useful for making custom keyboard-shortcuts
– Vassilis
Oct 13 '17 at 11:24
This does not work in Ubuntu 16.04 on a virtualbox.
– Juha Untinen
Feb 15 '18 at 9:48
add a comment |
Just out of curiosity, why would you do that ? Why would you open a terminal and they type a command to switch your keyboard layout when you can do so by a simple keyboard shortcut ! Assuming you use Ubuntu , it goes as Windows
+ Space
2
This appears to be more of a comment and less of an answer.
– WinEunuuchs2Unix
Feb 26 '17 at 15:48
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
– Eyal
Mar 8 '17 at 19:33
also it is useful for making custom keyboard-shortcuts
– Vassilis
Oct 13 '17 at 11:24
This does not work in Ubuntu 16.04 on a virtualbox.
– Juha Untinen
Feb 15 '18 at 9:48
add a comment |
Just out of curiosity, why would you do that ? Why would you open a terminal and they type a command to switch your keyboard layout when you can do so by a simple keyboard shortcut ! Assuming you use Ubuntu , it goes as Windows
+ Space
Just out of curiosity, why would you do that ? Why would you open a terminal and they type a command to switch your keyboard layout when you can do so by a simple keyboard shortcut ! Assuming you use Ubuntu , it goes as Windows
+ Space
answered Feb 26 '17 at 15:08
EetSandhuEetSandhu
4319
4319
2
This appears to be more of a comment and less of an answer.
– WinEunuuchs2Unix
Feb 26 '17 at 15:48
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
– Eyal
Mar 8 '17 at 19:33
also it is useful for making custom keyboard-shortcuts
– Vassilis
Oct 13 '17 at 11:24
This does not work in Ubuntu 16.04 on a virtualbox.
– Juha Untinen
Feb 15 '18 at 9:48
add a comment |
2
This appears to be more of a comment and less of an answer.
– WinEunuuchs2Unix
Feb 26 '17 at 15:48
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
– Eyal
Mar 8 '17 at 19:33
also it is useful for making custom keyboard-shortcuts
– Vassilis
Oct 13 '17 at 11:24
This does not work in Ubuntu 16.04 on a virtualbox.
– Juha Untinen
Feb 15 '18 at 9:48
2
2
This appears to be more of a comment and less of an answer.
– WinEunuuchs2Unix
Feb 26 '17 at 15:48
This appears to be more of a comment and less of an answer.
– WinEunuuchs2Unix
Feb 26 '17 at 15:48
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
– Eyal
Mar 8 '17 at 19:33
Right before my screensaver turns on, I want to switch to English so that it will be easy to type my password when I get back in.
– Eyal
Mar 8 '17 at 19:33
also it is useful for making custom keyboard-shortcuts
– Vassilis
Oct 13 '17 at 11:24
also it is useful for making custom keyboard-shortcuts
– Vassilis
Oct 13 '17 at 11:24
This does not work in Ubuntu 16.04 on a virtualbox.
– Juha Untinen
Feb 15 '18 at 9:48
This does not work in Ubuntu 16.04 on a virtualbox.
– Juha Untinen
Feb 15 '18 at 9:48
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f209597%2fhow-do-i-change-keyboards-from-the-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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