Switch capslock and ctrl with config file on ubuntu 18.04
Recently, I tried to switch capslock and ctrl on my Ubuntu 18.04. I did it by add the following line into my .bashrc
:
# swap capslock and ctrl
/usr/bin/setxkbmap -option "ctrl:swapcaps"
This worked, but in an awkward way. Every time I logged in by GUI, I need to start a new terminal to activate this setting. And sometimes when I locked the desktop and then logged in back, this setting is deactivated and I had to source .bashrc
to activate it again.
I wanted to find a way to activate this setting automatically upon my logging in by GUI. I searched around and find that there are log-in bash and non-log-in bash. I believe when I logged in by GUI, I actually started a log-in bash. So I put my setting in ~/.profile
. But it did not even work any more!
So is there any approach to automating the activating of the setting? And what happened when I logged in by GUI? I mean, if it does not start a log-in bash, how could I start other application on GUI?
ubuntu keyboard-shortcuts keyboard bashrc
add a comment |
Recently, I tried to switch capslock and ctrl on my Ubuntu 18.04. I did it by add the following line into my .bashrc
:
# swap capslock and ctrl
/usr/bin/setxkbmap -option "ctrl:swapcaps"
This worked, but in an awkward way. Every time I logged in by GUI, I need to start a new terminal to activate this setting. And sometimes when I locked the desktop and then logged in back, this setting is deactivated and I had to source .bashrc
to activate it again.
I wanted to find a way to activate this setting automatically upon my logging in by GUI. I searched around and find that there are log-in bash and non-log-in bash. I believe when I logged in by GUI, I actually started a log-in bash. So I put my setting in ~/.profile
. But it did not even work any more!
So is there any approach to automating the activating of the setting? And what happened when I logged in by GUI? I mean, if it does not start a log-in bash, how could I start other application on GUI?
ubuntu keyboard-shortcuts keyboard bashrc
If you're using GNOME I recommend doing it via its own tools as it overrides thexkb
options set in xorg.conf files
– don_crissti
Dec 30 '18 at 13:24
add a comment |
Recently, I tried to switch capslock and ctrl on my Ubuntu 18.04. I did it by add the following line into my .bashrc
:
# swap capslock and ctrl
/usr/bin/setxkbmap -option "ctrl:swapcaps"
This worked, but in an awkward way. Every time I logged in by GUI, I need to start a new terminal to activate this setting. And sometimes when I locked the desktop and then logged in back, this setting is deactivated and I had to source .bashrc
to activate it again.
I wanted to find a way to activate this setting automatically upon my logging in by GUI. I searched around and find that there are log-in bash and non-log-in bash. I believe when I logged in by GUI, I actually started a log-in bash. So I put my setting in ~/.profile
. But it did not even work any more!
So is there any approach to automating the activating of the setting? And what happened when I logged in by GUI? I mean, if it does not start a log-in bash, how could I start other application on GUI?
ubuntu keyboard-shortcuts keyboard bashrc
Recently, I tried to switch capslock and ctrl on my Ubuntu 18.04. I did it by add the following line into my .bashrc
:
# swap capslock and ctrl
/usr/bin/setxkbmap -option "ctrl:swapcaps"
This worked, but in an awkward way. Every time I logged in by GUI, I need to start a new terminal to activate this setting. And sometimes when I locked the desktop and then logged in back, this setting is deactivated and I had to source .bashrc
to activate it again.
I wanted to find a way to activate this setting automatically upon my logging in by GUI. I searched around and find that there are log-in bash and non-log-in bash. I believe when I logged in by GUI, I actually started a log-in bash. So I put my setting in ~/.profile
. But it did not even work any more!
So is there any approach to automating the activating of the setting? And what happened when I logged in by GUI? I mean, if it does not start a log-in bash, how could I start other application on GUI?
ubuntu keyboard-shortcuts keyboard bashrc
ubuntu keyboard-shortcuts keyboard bashrc
edited Dec 25 '18 at 2:12
Jeff Schaller
39k1053125
39k1053125
asked Dec 25 '18 at 1:54
Rivers Shall
62
62
If you're using GNOME I recommend doing it via its own tools as it overrides thexkb
options set in xorg.conf files
– don_crissti
Dec 30 '18 at 13:24
add a comment |
If you're using GNOME I recommend doing it via its own tools as it overrides thexkb
options set in xorg.conf files
– don_crissti
Dec 30 '18 at 13:24
If you're using GNOME I recommend doing it via its own tools as it overrides the
xkb
options set in xorg.conf files– don_crissti
Dec 30 '18 at 13:24
If you're using GNOME I recommend doing it via its own tools as it overrides the
xkb
options set in xorg.conf files– don_crissti
Dec 30 '18 at 13:24
add a comment |
1 Answer
1
active
oldest
votes
Place this in file /etc/X11/xorg.conf.d/50-keyboard.conf for example:
Section "InputClass"
Identifier "my laptop keyboard"
MatchIsKeyboard "on"
MatchProduct "AT Translated Set 2"
# Option "XkbModel" "asus_laptop"
# Option "XkbLayout" "us"
Option "XkbOptions" "caps:none"
EndSection
Be sure to change the MatchProduct to your own if that doesn't work. Look in Xorg.0.log for the product name.
The XkbModel and XkbLayout are optional so can be automatically selected by Xorg defaults or customized.
The XkbOptions is where you put your options to swap the keys or turn off CapsLock as I have done.
Reference: "man xkeyboard-config"
EDIT: I have Debian installed on several of my machines while I now prefer voidlinux. I think the xorg.conf is about the same for Ubuntu.
Create the directory /etc/X11/xorg.conf.d if that does not exist. See the xorg.conf man page for details.
The common way to modify the Xorg is by placing your own config files in /etc/X11/xorg.conf.d/ and making sure they are used instead of the automatic config files in /usr/share/X11/xorg.conf.d/ by checking the /var/log/Xorg.0.log file.
There is noxorg.conf.d
directory under/etc/X11
path at all. Are you sure you are using Ubuntu 18.04?
– Rivers Shall
Dec 30 '18 at 3:15
The /etc/X11/xorg.conf.d directory should be created if not found. I edited my above answer with more information.
– beginner6789
Dec 30 '18 at 12:51
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f490832%2fswitch-capslock-and-ctrl-with-config-file-on-ubuntu-18-04%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
Place this in file /etc/X11/xorg.conf.d/50-keyboard.conf for example:
Section "InputClass"
Identifier "my laptop keyboard"
MatchIsKeyboard "on"
MatchProduct "AT Translated Set 2"
# Option "XkbModel" "asus_laptop"
# Option "XkbLayout" "us"
Option "XkbOptions" "caps:none"
EndSection
Be sure to change the MatchProduct to your own if that doesn't work. Look in Xorg.0.log for the product name.
The XkbModel and XkbLayout are optional so can be automatically selected by Xorg defaults or customized.
The XkbOptions is where you put your options to swap the keys or turn off CapsLock as I have done.
Reference: "man xkeyboard-config"
EDIT: I have Debian installed on several of my machines while I now prefer voidlinux. I think the xorg.conf is about the same for Ubuntu.
Create the directory /etc/X11/xorg.conf.d if that does not exist. See the xorg.conf man page for details.
The common way to modify the Xorg is by placing your own config files in /etc/X11/xorg.conf.d/ and making sure they are used instead of the automatic config files in /usr/share/X11/xorg.conf.d/ by checking the /var/log/Xorg.0.log file.
There is noxorg.conf.d
directory under/etc/X11
path at all. Are you sure you are using Ubuntu 18.04?
– Rivers Shall
Dec 30 '18 at 3:15
The /etc/X11/xorg.conf.d directory should be created if not found. I edited my above answer with more information.
– beginner6789
Dec 30 '18 at 12:51
add a comment |
Place this in file /etc/X11/xorg.conf.d/50-keyboard.conf for example:
Section "InputClass"
Identifier "my laptop keyboard"
MatchIsKeyboard "on"
MatchProduct "AT Translated Set 2"
# Option "XkbModel" "asus_laptop"
# Option "XkbLayout" "us"
Option "XkbOptions" "caps:none"
EndSection
Be sure to change the MatchProduct to your own if that doesn't work. Look in Xorg.0.log for the product name.
The XkbModel and XkbLayout are optional so can be automatically selected by Xorg defaults or customized.
The XkbOptions is where you put your options to swap the keys or turn off CapsLock as I have done.
Reference: "man xkeyboard-config"
EDIT: I have Debian installed on several of my machines while I now prefer voidlinux. I think the xorg.conf is about the same for Ubuntu.
Create the directory /etc/X11/xorg.conf.d if that does not exist. See the xorg.conf man page for details.
The common way to modify the Xorg is by placing your own config files in /etc/X11/xorg.conf.d/ and making sure they are used instead of the automatic config files in /usr/share/X11/xorg.conf.d/ by checking the /var/log/Xorg.0.log file.
There is noxorg.conf.d
directory under/etc/X11
path at all. Are you sure you are using Ubuntu 18.04?
– Rivers Shall
Dec 30 '18 at 3:15
The /etc/X11/xorg.conf.d directory should be created if not found. I edited my above answer with more information.
– beginner6789
Dec 30 '18 at 12:51
add a comment |
Place this in file /etc/X11/xorg.conf.d/50-keyboard.conf for example:
Section "InputClass"
Identifier "my laptop keyboard"
MatchIsKeyboard "on"
MatchProduct "AT Translated Set 2"
# Option "XkbModel" "asus_laptop"
# Option "XkbLayout" "us"
Option "XkbOptions" "caps:none"
EndSection
Be sure to change the MatchProduct to your own if that doesn't work. Look in Xorg.0.log for the product name.
The XkbModel and XkbLayout are optional so can be automatically selected by Xorg defaults or customized.
The XkbOptions is where you put your options to swap the keys or turn off CapsLock as I have done.
Reference: "man xkeyboard-config"
EDIT: I have Debian installed on several of my machines while I now prefer voidlinux. I think the xorg.conf is about the same for Ubuntu.
Create the directory /etc/X11/xorg.conf.d if that does not exist. See the xorg.conf man page for details.
The common way to modify the Xorg is by placing your own config files in /etc/X11/xorg.conf.d/ and making sure they are used instead of the automatic config files in /usr/share/X11/xorg.conf.d/ by checking the /var/log/Xorg.0.log file.
Place this in file /etc/X11/xorg.conf.d/50-keyboard.conf for example:
Section "InputClass"
Identifier "my laptop keyboard"
MatchIsKeyboard "on"
MatchProduct "AT Translated Set 2"
# Option "XkbModel" "asus_laptop"
# Option "XkbLayout" "us"
Option "XkbOptions" "caps:none"
EndSection
Be sure to change the MatchProduct to your own if that doesn't work. Look in Xorg.0.log for the product name.
The XkbModel and XkbLayout are optional so can be automatically selected by Xorg defaults or customized.
The XkbOptions is where you put your options to swap the keys or turn off CapsLock as I have done.
Reference: "man xkeyboard-config"
EDIT: I have Debian installed on several of my machines while I now prefer voidlinux. I think the xorg.conf is about the same for Ubuntu.
Create the directory /etc/X11/xorg.conf.d if that does not exist. See the xorg.conf man page for details.
The common way to modify the Xorg is by placing your own config files in /etc/X11/xorg.conf.d/ and making sure they are used instead of the automatic config files in /usr/share/X11/xorg.conf.d/ by checking the /var/log/Xorg.0.log file.
edited Dec 30 '18 at 12:46
answered Dec 27 '18 at 14:11
beginner6789
914
914
There is noxorg.conf.d
directory under/etc/X11
path at all. Are you sure you are using Ubuntu 18.04?
– Rivers Shall
Dec 30 '18 at 3:15
The /etc/X11/xorg.conf.d directory should be created if not found. I edited my above answer with more information.
– beginner6789
Dec 30 '18 at 12:51
add a comment |
There is noxorg.conf.d
directory under/etc/X11
path at all. Are you sure you are using Ubuntu 18.04?
– Rivers Shall
Dec 30 '18 at 3:15
The /etc/X11/xorg.conf.d directory should be created if not found. I edited my above answer with more information.
– beginner6789
Dec 30 '18 at 12:51
There is no
xorg.conf.d
directory under /etc/X11
path at all. Are you sure you are using Ubuntu 18.04?– Rivers Shall
Dec 30 '18 at 3:15
There is no
xorg.conf.d
directory under /etc/X11
path at all. Are you sure you are using Ubuntu 18.04?– Rivers Shall
Dec 30 '18 at 3:15
The /etc/X11/xorg.conf.d directory should be created if not found. I edited my above answer with more information.
– beginner6789
Dec 30 '18 at 12:51
The /etc/X11/xorg.conf.d directory should be created if not found. I edited my above answer with more information.
– beginner6789
Dec 30 '18 at 12:51
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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.
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%2funix.stackexchange.com%2fquestions%2f490832%2fswitch-capslock-and-ctrl-with-config-file-on-ubuntu-18-04%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
If you're using GNOME I recommend doing it via its own tools as it overrides the
xkb
options set in xorg.conf files– don_crissti
Dec 30 '18 at 13:24