Closed probonopd closed 1 year ago
git clone --depth 1 --filter=blob:none --no-checkout https://github.com/freebsd/freebsd
cd freebsd/
git checkout master -- usr.sbin/efivar/
cd usr.sbin/efivar/
sudo wget "https://bz-attachments.freebsd.org/attachment.cgi?id=219556" -O efivar-251025.patch
sudo patch -p3 < efivar-251025.patch
# Works, but cannot compile:
# efivar.c:43:10: fatal error: 'efichar.h' file not found
# So we need to get the full FreeBSD source:
sudo svnlite checkout https://svn.freebsd.org/base/releng/12.1 /usr/src/
# Ends with
# svn: E000060: Operation timed out
Trying that (or any) variable from Linux also fails...
root@clr-c4de0fbeed1845a1964af041ea6e2062/home/me # chmod +x youtube-dl ^C
root@clr-c4de0fbeed1845a1964af041ea6e2062/home/me # sudo efivar -w -n '7C436110-AB2A-4BBB-A880-FE41995C9F82-prev-lang:kbd' -f=/home/me/input
Could not use "=/home/me/input": No such file or directory
root@clr-c4de0fbeed1845a1964af041ea6e2062/home/me # sudo efivar -w -n '7C436110-AB2A-4BBB-A880-FE41995C9F82-prev-lang:kbd' -f /home/me/input
efivar: Input/output error
root@clr-c4de0fbeed1845a1964af041ea6e2062/home/me # cat input
de:3
The bootloader can read and write EFI variables. I have set this variable by typing the long string in the bootloader, with the result that helloSystem Live ISOs now use the correct keyboard layout, language, and timezone for the desktop.
Extending this idea, we could always try to standardize on some commonly used UNIX environment variables for persisting them in EFI NVRAM, if really no one before us (besides Apple in a somewhat undocumented? way) has ever thought of this. Result: Linux and BSD Live ISOs would boot using the correct language, keyboard layout, and timezone without having to fiddle around which each one.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=251025 has since been merged. Now the question is, in which version(s) of FreeBSD will this show up eventually?
In the meantime, we could compile our own using the procedure outlined on https://hellosystem.github.io/docs/developer/base.
Still broken in 13.0:
% echo -n 'de:3\0' | sudo efivar -w -n '7C436110-AB2A-4BBB-A880-FE41995C9F82-prev-lang:kbd'
efivar: Invalid guid 7C436110-AB2A-4BBB-A880-FE41995C9F82-prev
% freebsd-version
13.0-RELEASE
# Version
root@Users-Laptop:~ # uname -a
FreeBSD Users-Laptop 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC amd64
# Set the variable
root@Users-Laptop:~ # echo -n 'de:3\0' | sudo efivar -w -n '7C436110-AB2A-4BBB-A880-FE41995C9F82-prev-lang:kbd'
# Read it back
root@Users-Laptop:~ # efivar -p -A 7c436110-ab2a-4bbb-a880-fe41995c9f82-prev-lang:kbd
7c436110-ab2a-4bbb-a880-fe41995c9f82-prev-lang:kbd
de:3\0
So we can now write a little GUI to set this variable :+1:
We need to construct a translation table between the prev-lang:kbd
values and the xkbmap layout
and LOCALE
used on Unix-like systems.
Let's crowd-source this in the Wiki: https://github.com/helloSystem/hello/wiki/EFI-NVRAM
Contributions welcome!
Write keyboard layout and language to EFI variable. How?