Advertising

Welcome to SparkyLinux forums
Zapraszamy również na polsko-języczne Forum https://forum.linuxiarze.pl

[SOLVED] two keyboards - how to configure layout?

Started by dirkskep, May 12, 2024, 02:19:26 AM

Previous topic - Next topic

dirkskep

I installed Sparky on an older Macbook Pro
I have physically installed a second keyboard (USB - non Apple) but this does not have the same exact layout...
It's a bit annoying having to look at my Macbook keyboard when I need to find a specific character...

Is there a way to configure a second keyboard layout?


duststuff

Do you need to be able to use both keyboards at the same time? Not sure what version of Sparky you have, but on my Sparky 7.3 here, I would probably start by going to the 'Apps' menu, opening 'Keyboard', going to the 'Layout' tab and then adding the second keyboard layout. Not sure if there's a way to have more than one keyboard layout active (i.e. each one linked to a specific keyboard) at the same time using these settings or not, but there's probably a way you can switch between the layouts as necessary via these settings or maybe a keyboard shortcut of some kind. If these settings don't do what you want them to, you could also search online for other keyboard layout controlling software that might.

dirkskep

Thank you @duststuff,

It would be best to have both keyboards defined, I supose X11 can manage that?

My Sparky version (from "inxi -br"):
System:
  Host: sparkbook Kernel: 6.1.0-20-amd64 arch: x86_64 bits: 64
    Desktop: Openbox v: 3.6.1 Distro: SparkyLinux 7.3 (Orion-Belt)
Machine:
  Type: Laptop System: Apple product: MacBookPro11,2 v: 1.0
    serial: <superuser required>
  Mobo: Apple model: Mac-3CBD00234E554E41 v: MacBookPro11,2
    serial: <superuser required> UEFI: Apple v: 478.0.0.0.0 date: 01/13/2023
Battery:
  ID-1: BAT0 charge: 67.3 Wh (100.0%) condition: 67.3/95.4 Wh (70.5%)
CPU:
  Info: quad core Intel Core i7-4870HQ [MT MCP] speed (MHz): avg: 799
    min/max: 800/3700
Graphics:
  Device-1: Intel Crystal Well Integrated Graphics driver: i915 v: kernel
  Device-2: GEMBIRD Generic UVC 1.00 camera [AppoTech AX2311] type: USB
    driver: uvcvideo
  Display: x11 server: X.Org v: 1.21.1.7 driver: X: loaded: modesetting
    unloaded: fbdev,vesa dri: crocus gpu: i915 resolution: 1: 3072x1728~30Hz
    2: 2304x1440~60Hz
  API: OpenGL v: 4.6 Mesa 22.3.6 renderer: Mesa Intel Iris Pro Graphics
    P5200 (HSW GT3)
Network:
  Device-1: Broadcom BCM4360 802.11ac Wireless Network Adapter driver: wl
  Device-2: Realtek RTL8153 Gigabit Ethernet Adapter type: USB driver: r8152
Drives:
  Local Storage: total: 356.74 GiB used: 52.58 GiB (14.7%)
Repos:
  Active apt repos in: /etc/apt/sources.list
    1: deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
    2: deb-src http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware
    3: deb http://security.debian.org/debian-security/ bookworm-security/updates main contrib non-free non-free-firmware
    4: deb-src http://security.debian.org/debian-security/ bookworm-security/updates main contrib non-free non-free-firmware
    5: deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
    6: deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
    7: deb http://deb-multimedia.org/ bookworm main non-free
  No active apt repos in: /etc/apt/sources.list.d/liquorix.list
  Active apt repos in: /etc/apt/sources.list.d/sparky.list
    1: deb [signed-by=/usr/share/keyrings/sparky.gpg.key] https://repo.sparkylinux.org/ core main
    2: deb-src [signed-by=/usr/share/keyrings/sparky.gpg.key] https://repo.sparkylinux.org/ core main
    3: deb [signed-by=/usr/share/keyrings/sparky.gpg.key] https://repo.sparkylinux.org/ orion main
    4: deb-src [signed-by=/usr/share/keyrings/sparky.gpg.key] https://repo.sparkylinux.org/ orion main
Info:
  Processes: 276 Uptime: 17h 59m Memory: 15.53 GiB used: 5.69 GiB (36.6%)
  Shell: Bash inxi: 3.3.26

duststuff

I haven't done a lot of what you're trying to do, but from the various keyboard layout settings dialogs I've seen over the years in this and similar distros, it seems likely to me that you can set up multiple keyboard layouts and then switch between them in some way. Usually an installer always includes the setting of one's keyboard layout, which is likely what becomes the default, but I'm assuming you can add one or more as desired. I'm using Xfce for my desktop, and it looks like you're using OpenBox, so the approach may / will likely be different as far as how you access / change settings, etc. Not sure how proficient you are with Linux, Debian, Sparky, and/or OpenBox, but your next best step is likely to see if the Apps menu already has a graphical user interface (GUI) for keyboard layout settings. If it doesn't, then I would do some online searches with keywords like 'openbox', 'configuration', 'keyboard layout', etc. Haven't used OpenBox on its own much, but my sense is that you can do a fair amount of configuration with it, but that it's a bit less 'user-friendly' in the sense that you may need to be using a text editor to change a settings file rather than doing it through a GUI. However, I 'think' that the OpenBox that comes with Sparky has some extra features added to it by the Sparky developers that might make it a bit easier to use.

dirkskep

Thanks again!

In the mean time I was checking other sources but nothing is clear...
I'm impressed nobody uses another keyboard on their laptops (layout almost never matches 100%)

If I understand correctly it should not be an issue at all...
setxkbmap has the "-device" option allowing to configure that second (or whatever) keyboard...
I'm not there yet, I'm not getting the syntax right, the device id I tried seems incorrect... (I used the device id from "lsusb")

dda@sparkbook:~$ lsusb
Bus 002 Device 003: ID 05ac:8406 Apple, Inc. Internal Memory Card Reader
Bus 002 Device 005: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
Bus 002 Device 004: ID 152d:1561 JMicron Technology Corp. / JMicron USA Technology Corp. JMS561U two ports SATA 6Gb/s bridge
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp. Hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 013: ID 05ac:8289 Apple, Inc. Bluetooth Host Controller
Bus 001 Device 005: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 001 Device 067: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 001 Device 003: ID 0bda:5411 Realtek Semiconductor Corp. RTS5411 Hub
Bus 001 Device 009: ID 05ac:0263 Apple, Inc. Apple Internal Keyboard / Trackpad (MacBook Retina)
Bus 001 Device 064: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse
Bus 001 Device 051: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
dda@sparkbook:~$ setxkbmap -device 067 fr
X Error of failed request:  129
  Major opcode of failed request:  135 (XKEYBOARD)
  Minor opcode of failed request:  23 (XkbGetKbdByName)
  Value in failed request:  0xff000043
  Serial number of failed request:  15
  Current serial number in output stream:  15
dda@sparkbook:~$

duststuff

#5
You're welcome, dirkskep. :-) I haven't used setxkbmap before, but I think the next thing I would try is to use '0002' for the device ID, since it may be looking for the actual hardware ID rather than the bus device number that the system assigns to it. You may already know this, but with a hardware ID string like '1c4f:0002' (i.e. your target keyboard), the first set of four characters before the colon is the numeric ID for the manufacturer and the second set after the colon is the numeric ID for the device. I've found these to often be helpful when searching online for solutions while troubleshooting devices.

Update: The following link looks like it's the same or a similar issue to your use case, in case you haven't seen it yet: https://jpriest.me/post/using-setxkbmap/ . From there it seems like my above comment about the ID is probably wrong, but I haven't tried to test / confirm. If you haven't seen this page yet, it might be what helps you solve your issue, especially in regards to the setxkbmap syntax as well as making it persistent. Another similar (but older) link is https://superuser.com/questions/757170/setxkbmap-how-to-apply-options-to-a-specific-device-only and that page also includes a link to an even older page that you may also find helpful. Other more general resources that you may have already seen are at the links below:

https://wiki.debian.org/Keyboard
https://wiki.archlinux.org/title/Xorg/Keyboard_configuration

dirkskep

Thx once more duststuff... Problem Solved!

Indeed lsusb gave me a wrong id...
I installed xinput which gives me several id's for the external USB keyboard...

dda@sparkbook:~$ dda@sparkbook:~$ xinput -list | grep -i "USB keyboard"
⎜   ↳ SIGMACHIP USB Keyboard Consumer Control id=14 [slave  pointer  (2)]
    ↳ SIGMACHIP USB Keyboard System Control    id=13 [slave  keyboard (3)]
    ↳ SIGMACHIP USB Keyboard Consumer Control id=15 [slave  keyboard (3)]
    ↳ SIGMACHIP USB Keyboard                  id=17 [slave  keyboard (3)]
dda@sparkbook:~$

And with
dda@sparkbook:~$ setxkbmap -device 17 fr
dda@sparkbook:~$
My additional keyboard now has the correct layout !
(While the laptop mac layout remained unchanged)

duststuff

Glad to hear it, dirkskep. :-) If you could do one more thing and add something like '[Solved]' to the beginning or end of this thread's title, that would be helpful for anyone else searching these forums for a solution to the same problem. Enjoy using your keyboard(s) without the previous distraction / annoyance. :-)

dirkskep

Quote from: duststuff on May 14, 2024, 05:59:15 PMGlad to hear it, dirkskep. :-) If you could do one more thing and add something like '[Solved]' to the beginning or end of this thread's title, that would be helpful for anyone else searching these forums for a solution to the same problem.

Would love to but don't see where I can edit the thread title...
Maybe this is a moderator priviledge?

duststuff

Quote from: dirkskep on May 14, 2024, 07:54:18 PM
Quote from: duststuff on May 14, 2024, 05:59:15 PMGlad to hear it, dirkskep. :-) If you could do one more thing and add something like '[Solved]' to the beginning or end of this thread's title, that would be helpful for anyone else searching these forums for a solution to the same problem.

Would love to but don't see where I can edit the thread title...
Maybe this is a moderator priviledge?

No, anyone can do it for a topic they've created, although presumably you would need to be signed in. See this sticky post. Basically, you just edit the first post in the thread; to do that, go to the bottom right of the post and it looks like you can use either 'Quick Edit' or 'More...'-'Modify' to get to a page where you can make the change and save it, etc.

dirkskep

Done... Marked as Solved, I'm sure this will help others...

TRon

I would like to add that I recently encountered a similar situation with an old Acer laptop (+10 years old) and that adding an additional layout using the keyboard system settings as described by duststuff in reply #1 was enough for me to get both the internal keyboard (Italian Acer specific layout) and an external USB keyboard (US layout) to work simultaneously without issues (though I do encounter some issues when switching from internal to external when in the middle of composing a key but that does not strike me as out of the ordinary).

View the most recent posts on the forum