systemd / systemd

The systemd System and Service Manager
https://systemd.io
GNU General Public License v2.0
13.19k stars 3.77k forks source link

Make systemd-localed use the prev-lang:kbd EFI NVRAM variable #25043

Open probonopd opened 2 years ago

probonopd commented 2 years ago

Component

systemd-localed

Is your feature request related to a problem? Please describe

It is frustrating that you always have to set keyboard layout for each operating system; this is especially annoying for Live ISO systems and multi-boot configurations.

Describe the solution you'd like

Use the EFI NVRAM variable 7C436110-AB2A-4BBB-A880-FE41995C9F82:prev-lang:kbd. macOS reads and writes this variable.

Describe alternatives you've considered

No response

The systemd version you checked that didn't have the feature you are asking for

No response

poettering commented 1 year ago

Interesting. Is there any documentation available for this? i.e. expected vocabulary and stuff?

probonopd commented 1 year ago

Hi @poettering. While the format of the prev-lang:kbd variable doesn't seem to be publicly documented by Apple, it appears to be rather straightforward and well understood by the community:

The variable contains an ASCII string which describes the keyboard layout. The format is lang-COUNTRY:keyboard, e.g. ru-RU:252 for Russian locale and ABC keyboard. Also accepts short forms: ru:252 or ru:0.

The full list of allowable combinations can be found here:

https://github.com/acidanthera/OpenCorePkg/blob/master/Utilities/AppleKeyboardLayouts/AppleKeyboardLayouts.txt

Most likely one would need a translation table to translate between this notation and the notation commonly used on Unix systems.

Live ISO systems may use the same information to intelligently guess the (default) system language based on this information in addition to the keyboard layout.

Please let me know if you are interested in implementing support for this, in which case I'd be happy to do additional research and possibly put together a translation table.

Thanks for considering!