# Xorg  and keyboard,  help!



## teo (Jan 26, 2020)

Good morning!

I am running FreeBSD as a guest system in Virtualbox and need to add keyboard setting for the xorg.conf file  and get the desired language, how do I proceed?

In the window managers it is essential  add the keyboard configuration for the  Xorg file because it does not detect the system  the desired of keyboard language in thes .profile or  .xinitrc and  login.conf   or ~/.bashrc  files.


----------



## yuripv (Jan 26, 2020)

I'm not sure if I understand the question correctly, but to switch keyboard layouts I use the following command (added to .xinitrc):

```
setxbkmap -layout us,ru -option grp:caps_toggle
```

That is switching between us and ru layouts using CapsLock (got used to it in macos).

Also see the xkeyboard-config(7) man page for other modifiers and options.


----------



## aragats (Jan 26, 2020)

teo said:


> it does not detect the desired keyboard language in thes files of .profile or .xinitrc files


There is no such think as "detection", you have to *set* your desired keyboard layout. To me the easiest way is using x11/setxkbmap, which can be launched from ~/.xinitrc. You can use Xorg configuration files as well. Your question is not FreeBSD related, there are many resources explaining available options, e.g. Arch wiki.


----------



## teo (Jan 26, 2020)

aragats said:


> You can use Xorg configuration files as well.



That's what I want to proceed to put the keyboard configuration in the desired language in the Xorg file so that it detects the system with the window manager, example FluxBox. Remember that I am running FreeBSD as a guest system in virtualbox.


----------



## aragats (Jan 26, 2020)

It's purely an Xorg setting ― not related to the WM.
I think you do not formulate your question properly, it is not clear what Xorg your are talking about: one running in the host OS or in the guest?


----------



## T-Daemon (Jan 26, 2020)

teo said:


> Remember that I am running FreeBSD as a guest system in virtualbox in the guest system.


That doesn't exclude using setxkbmap(1) in the guest system.

But if you insists on xorg configuration (in the guest system), in the handbook, chapter 5.4.7.1. Keyboards, it is explained how to set keyboard layouts, with examples.


----------



## teo (Jan 26, 2020)

aragats said:


> It's purely an Xorg setting ― not related to the WM.
> I think you do not formulate your question properly, it is not clear what Xorg your are talking about: one running in the host OS or in the guest?


Xorg this  installed in the guest system that is FreeBSD, add the language to those files mentioned above so that it detects the keyboard in the desired language however when entering the window manager it does not detect the keyboard in the desired language.


----------



## aragats (Jan 26, 2020)

How do you access the guest? Via VNC?
It could be a conflict between your host keyboard layout and the guest layout.
As other people and myself mentioned above, try using setxbmap() in a terminal running in the guest to understand whether it's an Xorg issue or something else. It perfectly works in any scenarios, and I use it as preferred method in all my computers with a simple wrapper I wrote to indicate the actual layout with an icon in the status bar. Again, you don't have to use it, but it's worth checking to understand the issue.


----------



## teo (Jan 26, 2020)

aragats said:


> How do you access the guest? Via VNC?


 I don't understand what you mean by VNC? The virtual machine is accessing the guests by Adding Guests.  When the guest system is installed, the guest system detects what is on the main system hardware, in this case the keyboard and others.


----------



## Emrion (Jan 26, 2020)

*T-Daemon *pointed the right chapiter in the handbook. Please, take time to read it.
It's exactly what I use concerning Xorg, no matter if it is a VM or not.


----------



## T-Daemon (Jan 27, 2020)

teo said:


> In the window managers it is essential add the keyboard configuration for the Xorg file because it does not detect the system the desired of keyboard language in thes .profile or .xinitrc and login.conf or ~/.bashrc files.



For present and future VirtualBox FreeBSD guest installations, if you are interested why the settings for the keyboard layout in the mentioned files are ineffective, you could share them here. In case you are concerned about privacy, copy & past only the relevant parts from those files.


----------



## teo (Jan 28, 2020)

Emrion said:


> *T-Daemon *pointed the right chapiter in the handbook. Please, take time to read it.
> It's exactly what I use concerning Xorg, no matter if it is a VM or not.


I proceed to add this to the Xorg configuration file, and it gave an error.

# `vi /usr/local/etc/X11/xorg.conf.d/keyboard-es-oss.conf`


```
Section  "InputClass"
                 Identifier    "KeyboardDefaults"
                Driver        "keyboard"
                MatchIsKeyboard    "on"
                Option        "XkbLayout" "es"
                Option        "XkbVariant" "oss"
EndSection
```


And:

#  vi /etc/xorg.conf


```
Section   "InputDevice"
               Identifier       "Keyboard0"
               Driver          "kbd"
               Option          "XkbModel"     "pc105"
              Option          "XkbLayout"     "es"
EndSection
```


Or:

# `vi /usr/local/etc/X11/xorg.conf.d/keyboard-fr-oss.conf`


```
Section "InputClass"
             Identifier  "FreeBSD DEVD kbdmux interface"
             MatchIsKeyboard  "on"
             MatchDevicePath  "/dev/kbdmux*"
             Driver  "keyboard"
            Option  "Protocol"  "standard"
            Option  "XkbRules"  "base"
            Option  "XkbLayout" "es"
            Option  "XkbModel"  "pc105"
EndSection
```


----------



## aragats (Jan 28, 2020)

The first wrong think I see is:


> Option        "XkbLayout" "es"
> Option        "XkbVariant" "oss"


"oss" is a variant of French, not Spanish. Check /usr/local/share/X11/xkb/rules/xorg.lst.

Why don't you want to use x11/setxkbmap to check your settings? Make sure they are correct, then add them to a *.conf file.


----------



## Emrion (Jan 28, 2020)

I don't use any xorg.conf and as far as I know, you shouldn't. You have to place your Xorg configuration files in /usr/local/etc/X11/xorg.conf.d/.
Have you tried to delete (or rename) xorg.conf and create a file, say /usr/local/etc/X11/xorg.conf.d/keyboard.conf like this?

```
Section   "InputClass"
               Identifier       "KeyboardDefaults"
               Driver          "keyboard"
               MatchIsKeyboard "on"
              Option          "XkbLayout"     "es"
EndSection
```

And if it doesn't work, what is the error you mention?


----------



## tonnyhals (Jan 29, 2020)

Really from this manual nothing helped you ??





						Xorg/Keyboard configuration - ArchWiki
					






					wiki.archlinux.org


----------



## teo (Jan 29, 2020)

Emrion said:


> I don't use any xorg.conf and as far as I know, you shouldn't. You have to place your Xorg configuration files in /usr/local/etc/X11/xorg.conf.d/.
> Have you tried to delete (or rename) xorg.conf and create a file, say /usr/local/etc/X11/xorg.conf.d/keyboard.conf like this?
> 
> ```
> ...



It seems that I have configured the keyboard of the  Xorg  file getting the desired language, thanks for your ideas. Finally it was like that and it didn't give any error.


# `vi /usr/local/etc/X11/xorg.conf.d/keyboard.conf`

```
Section  "InputClass"
              Identifier        "KeyboardDefaults"
              Driver            "keyboard"
              MatchIsKeyboard   "on"
              Option            "XkbLayout"     "es"
              Option            "XkbModel"      "pc105"
EndSection
```


----------



## kodcode (Jun 9, 2022)

yuripv said:


> I'm not sure if I understand the question correctly, but to switch keyboard layouts I use the following command (added to .xinitrc):
> 
> ```
> setxbkmap -layout us,ru -option grp:caps_toggle
> ```



Thanks!

Small fix: 
Should be `setxkbmap` and not setxbkmap.


----------

