Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ Each `--oem-script` is a bash script the install runs once, as root, in the new

The configurator asks for a language first, on the screen that carries the intro and the hidden Ctrl+C entry into preparing the machine for another owner. It offers every language in Omarchy's registry (`default/i18n/locales.json` in the settings package). A language with a catalog in `configs/airootfs/usr/share/omarchy-iso/i18n/` also translates the installer. The others are listed by their English name, the installer stays in English, and the language still goes to the installed system as `/etc/omarchy/language`. The keyboard list then preselects the language's layout from `language-defaults.json`. The timezone list preselects the network's guess, and when that fails, the capital of the language's country from the same file. English, Arabic, Swahili and Tamil have no single home country, so they fall back to the plain timezone search.

Catalogs exist only for languages the live console can draw. The kernel's own console fonts carry just the IBM PC character set, so the installer loads Terminus, patched by `console-font.py` with the half blocks the logo is drawn with. That covers Latin, Greek and Cyrillic. CJK, Arabic, Hebrew, the Indic scripts, Thai and Vietnamese are beyond any 512-glyph console font.
The kernel's own console fonts carry just the IBM PC character set, so the installer loads Terminus, patched by `console-font.py` with the half blocks the logo is drawn with. That covers Latin, Greek and Cyrillic, and those languages run on the plain console. Chinese, Japanese and Korean move the installer into kmscon (`omarchy-iso-kmscon`), which draws the same gum screens with fontconfig and the bundled Noto Sans Mono CJK. The configurator saves the answers so far and exits 75; `.automated_script.sh` starts kmscon on tty1 and runs itself again inside it, from the step after the language, and the rest of the install, the dashboard included, stays there. kmscon reads keys through XKB rather than the console keymap, so it is relaunched with the layout picked on the keyboard screen. Simplified Chinese, Japanese and Korean switch after the language screen, and kmscon draws Han characters in the picked language's forms from the same font collection. When kmscon cannot start, the answers resume on the console in English. zh-CN, ja and ko have catalogs so far, and only x86_64 ships kmscon; elsewhere these languages stay in English. Arabic, Hebrew, the Indic scripts, Thai and Vietnamese are beyond both and stay in English.

To add a string, put it in `en.json` and print it with `t <key> [args]`, where `%1`, `%2` take the arguments. A catalog that lacks the key shows it in English until a translation lands. `test/unit/test_installer_i18n.py` fails on a key English does not have, on placeholders that differ from English, and on a character the patched font cannot draw. The setup form vendored from Omarchy translates its own strings from Omarchy's catalogs, in the language the configurator names in `OMARCHY_FORM_LANGUAGE`, and takes the keyboard default and the offline timezone through `OMARCHY_FORM_KEYBOARD_DEFAULT` and `OMARCHY_FORM_TIMEZONE_FALLBACK`.
To add a string, put it in `en.json` and print it with `t <key> [args]`, where `%1`, `%2` take the arguments. A catalog that lacks the key shows it in English until a translation lands. `test/unit/test_installer_i18n.py` fails on a key English does not have, on placeholders that differ from English, and, outside the kmscon languages, on a character the patched font cannot draw. The setup form vendored from Omarchy translates its own strings from Omarchy's catalogs, in the language the configurator names in `OMARCHY_FORM_LANGUAGE`, and takes the keyboard default and the offline timezone through `OMARCHY_FORM_KEYBOARD_DEFAULT` and `OMARCHY_FORM_TIMEZONE_FALLBACK`.

## Creating the ISO

Expand Down
8 changes: 6 additions & 2 deletions builder/build-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,12 @@ if [[ $OMARCHY_ARCH == aarch64 ]]; then
# saves a laptop's signed firmware from Windows with qcom-firmware-extract.
arch_packages=("$OMARCHY_KERNEL" archlinuxarm-keyring git gum jq openssl openssh pciutils plymouth ttfx terminus-font tzupdate omarchy-keyring "$OMARCHY_SETTINGS_PACKAGE" lvm2 cryptsetup parted systemd-ukify systemd-stub-omarchy linux-firmware-qcom qcom-firmware-extract python)
else
# linux-t2 is the live kernel on a Mac (configs/grub/grub.cfg).
arch_packages=("$OMARCHY_KERNEL" linux-t2 git gum jq openssl plymouth ttfx terminus-font tzupdate omarchy-keyring "$OMARCHY_SETTINGS_PACKAGE" lvm2 cryptsetup parted)
# linux-t2 is the live kernel on a Mac (configs/grub/grub.cfg). kmscon and
# the CJK font carry the installer in the languages the Linux console cannot
# draw (usr/local/bin/omarchy-iso-kmscon); customize_airootfs.sh trims the
# font to the one face kmscon uses. aarch64 goes without until Arch Linux ARM
# builds kmscon, and stays in English for those languages.
arch_packages=("$OMARCHY_KERNEL" linux-t2 git gum jq openssl plymouth ttfx terminus-font tzupdate omarchy-keyring "$OMARCHY_SETTINGS_PACKAGE" lvm2 cryptsetup parted kmscon noto-fonts-cjk)
fi
live_packages_file="$build_cache_dir/packages.$OMARCHY_ARCH"
printf '%s\n' "${arch_packages[@]}" >> "$live_packages_file"
Expand Down
13 changes: 13 additions & 0 deletions configs/airootfs/etc/fonts/conf.d/60-omarchy-iso-cjk.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<!-- Live installer under kmscon: Latin from Adwaita Mono, CJK from the bundled
Noto Sans Mono CJK SC (two cells per glyph). -->
<fontconfig>
<alias binding="strong">
<family>monospace</family>
<prefer>
<family>Adwaita Mono</family>
<family>Noto Sans Mono CJK SC</family>
</prefer>
</alias>
</fontconfig>
40 changes: 34 additions & 6 deletions configs/airootfs/root/.automated_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
# - COLUMNS/LINES so gum picks up real terminal size
set -euo pipefail

[[ $(tty) == /dev/tty1 ]] || exit 0
# Inside kmscon (omarchy-iso-kmscon) this runs again on kmscon's pty, as the
# continuation of the tty1 installer in a language the console cannot draw.
[[ $(tty) == /dev/tty1 || ${OMARCHY_ISO_KMSCON:-} == 1 ]] || exit 0

# The N1x recovery boot entry is a diagnostic shell, never the installer: record
# the hardware probe, show how to reach the machine, and leave tty1 at a prompt.
Expand Down Expand Up @@ -50,7 +52,7 @@ set_tokyo_night_colors() {
echo -en "\033[0m"
clear
}
set_tokyo_night_colors
[[ ${OMARCHY_ISO_KMSCON:-} == 1 ]] || set_tokyo_night_colors

mkdir -p /var/log
touch "$OMARCHY_INSTALL_LOG_FILE"
Expand Down Expand Up @@ -126,9 +128,12 @@ warm_offline_mirror() {
done < <(du -k "$mirror"/*.pkg.tar.zst 2>/dev/null | sort -rn)
}

warm_offline_mirror &
warm_pid=$!
trap 'kill "$warm_pid" 2>/dev/null' EXIT
# Inside kmscon the tty1 run is still warming the cache.
if [[ ${OMARCHY_ISO_KMSCON:-} != 1 ]]; then
warm_offline_mirror &
warm_pid=$!
trap 'kill "$warm_pid" 2>/dev/null' EXIT
fi

cd /root
# Autoinstall: a cidata drive carrying the configurator's own output files
Expand All @@ -137,11 +142,34 @@ cd /root
if [[ -f /usr/share/omarchy-iso/oem-install ]]; then
export OMARCHY_UI_INTERACTIVE=no
./configurator --oem
elif [[ ${OMARCHY_ISO_KMSCON:-} == 1 ]]; then
# The tty1 run already looked for cidata.
./configurator && status=0 || status=$?
# A retry from the shell left after an abort: that shell, not the kmscon
# wrapper, gets the relaunch request, so end it to end kmscon.
if ((status == 75)) && [[ -n ${OMARCHY_ISO_KMSCON_SHELL:-} ]]; then
kill -HUP "$OMARCHY_ISO_KMSCON_SHELL" 2>/dev/null || true
fi
((status == 0)) || exit "$status"
elif /usr/local/bin/omarchy-cidata-load; then
echo "Autoinstall configuration found on cidata drive; skipping the configurator."
export OMARCHY_UI_INTERACTIVE=no
else
./configurator
./configurator && status=0 || status=$?
# 75: the configurator saved its answers and wants kmscon (a CJK language).
# kmscon runs this script again and the whole rest of the install in there;
# it is relaunched when the layout changes. If the configurator in kmscon
# never picked the answers up, the answers resume here in English.
while ((status == 75)); do
rm -f /run/omarchy-iso/kmscon-started
omarchy-iso-kmscon /root/.automated_script.sh || true
if [[ ! -e /run/omarchy-iso/kmscon-resume ]]; then
exit 0
elif [[ ! -e /run/omarchy-iso/kmscon-started ]]; then
OMARCHY_ISO_NO_KMSCON=1 ./configurator && status=0 || status=$?
fi
done
((status == 0)) || exit "$status"
fi

# Deferred-provisioning installs skip the celebration/reboot prompt and reboot on
Expand Down
112 changes: 94 additions & 18 deletions configs/airootfs/root/configurator
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ language_default() {
}

set_form_language() {
# The form's text comes from Omarchy's catalogs, which have every language;
# on a console that cannot draw this one it stays English like the rest.
OMARCHY_FORM_LANGUAGE=$language
i18n_translated "$language" || OMARCHY_FORM_LANGUAGE=en
OMARCHY_FORM_KEYBOARD_DEFAULT=$(language_default keyboard)
OMARCHY_FORM_KEYBOARD_DEFAULT=${OMARCHY_FORM_KEYBOARD_DEFAULT:-English (US)}
OMARCHY_FORM_TIMEZONE_FALLBACK=$(language_default timezone)
Expand All @@ -249,8 +252,12 @@ language_label() {

# "label<TAB>code" rows, English first and the rest alphabetical by what is shown.
language_rows() {
local translated
translated=$(cd "$OMARCHY_ISO_I18N_DIR" && printf '%s\n' *.json | sed 's/\.json$//' | jq -R . | jq -sc .)
local translated code
# Native names only for catalogs this console can draw: a CJK name would be
# boxes here, so Chinese is listed by its English name until kmscon takes over.
translated=$(for code in $(cd "$OMARCHY_ISO_I18N_DIR" && printf '%s\n' *.json | sed 's/\.json$//'); do
i18n_translated "$code" && printf '%s\n' "$code"
done | jq -R . | jq -sc .)
jq -r --argjson translated "$translated" '
to_entries
| map({code: .key, label: (if (.key | IN($translated[])) then .value.name else .value.englishName end)})
Expand Down Expand Up @@ -310,6 +317,7 @@ keyboard_form() {
if ((status == OMARCHY_FORM_BACK)); then
language_form
$defer_provisioning && return 0
kmscon_for_language
continue
fi

Expand All @@ -322,6 +330,50 @@ keyboard_form() {
if [[ $(tty 2>/dev/null) == "/dev/tty"* ]]; then
loadkeys "$keyboard" 2>/dev/null
fi

# kmscon reads keys through XKB and picks its font once, at its start:
# relaunch it with the layout just picked so the password is typed under the
# layout it will be entered with at boot, and with the Han forms of a
# language picked again on the way back (Chinese, then Japanese).
if [[ ${OMARCHY_ISO_KMSCON:-} == 1 ]] &&
[[ $(omarchy-iso-kmscon --xkb "$keyboard") != "${OMARCHY_ISO_KMSCON_XKB:-}" ||
$(omarchy-iso-kmscon --face "$language") != "${OMARCHY_ISO_KMSCON_FACE:-}" ]]; then
switch_to_kmscon user
fi
}

# ── kmscon handoff ──────────────────────────────────────────────────────────
#
# The configurator cannot move its own terminal, so a switch saves the answers
# so far and exits 75; .automated_script.sh starts kmscon, which runs the
# installer again from the saved stage. If kmscon cannot start, the same
# answers resume on this console in English.

KMSCON_RESUME=${KMSCON_RESUME:-/run/omarchy-iso/kmscon-resume}
KMSCON_SWITCH=75

kmscon_available() {
[[ ${OMARCHY_ISO_NO_KMSCON:-} != 1 && ${OMARCHY_ISO_KMSCON:-} != 1 ]] &&
[[ $(tty 2>/dev/null) == /dev/tty[0-9]* ]] && command -v kmscon >/dev/null
}

switch_to_kmscon() {
local resume_stage=$1
mkdir -p "$(dirname "$KMSCON_RESUME")"
(
umask 077
declare -p resume_stage language keyboard keyboard_label keyboard_input_method \
keyboard_xkb_layout defer_provisioning timezone username password password_hash hostname \
2>/dev/null >"$KMSCON_RESUME"
)
exit $KMSCON_SWITCH
}

# A language the console cannot draw: carry on in kmscon from the keyboard step.
kmscon_for_language() {
if i18n_needs_kmscon "$language" && kmscon_available; then
switch_to_kmscon keyboard
fi
}

# Ctrl+C on the first screen offers to prepare the machine for another owner.
Expand Down Expand Up @@ -883,11 +935,11 @@ run_partition_execute() {
# may assume it. It sets created_partition_number rather than printing so
# the rollback bookkeeping survives (a $(...) would subshell it away).
create_partition "$disk" "$EFI_START_B" "$EFI_END_B" fat32 OMARCHY_EFI ||
disk_abort_hook "Could not create the EFI partition on $disk"
disk_abort_hook "$(t partitions.efiFailed "$disk")"
efi_part_num="$created_partition_number"

create_partition "$disk" "$ROOT_START_B" "$ROOT_END_B" btrfs OMARCHY_ROOT ||
disk_abort_hook "Could not create the root partition on $disk"
disk_abort_hook "$(t partitions.rootFailed "$disk")"
root_part_num="$created_partition_number"

disk_step "flagging partition $efi_part_num as ESP" \
Expand All @@ -902,9 +954,9 @@ run_partition_execute() {
sync
sleep 2

wait_for_device "$efi_dev" || disk_abort_hook "EFI partition $efi_dev never appeared"
wait_for_device "$efi_dev" || disk_abort_hook "$(t partitions.efiMissing "$efi_dev")"
wait_for_device "$root_partition_device" ||
disk_abort_hook "Root partition $root_partition_device never appeared"
disk_abort_hook "$(t partitions.rootMissing "$root_partition_device")"

# Both partitions are ours and brand new, but the space they occupy may
# carry signatures from whatever was deleted to free it.
Expand Down Expand Up @@ -940,7 +992,7 @@ run_partition_execute() {
# full-disk path does the same through archinstall (archinstall_adapter).
disk_step "creating the Btrfs filesystem on $root_mapper" \
mkfs.btrfs -K -f -L OMARCHY "$root_mapper"
wait_for_device "$root_mapper" || disk_abort_hook "Root device $root_mapper never appeared"
wait_for_device "$root_mapper" || disk_abort_hook "$(t partitions.deviceMissing "$root_mapper")"

mkdir -p /mnt/btrfs-root
disk_step "mounting $root_mapper" mount "$root_mapper" /mnt/btrfs-root
Expand Down Expand Up @@ -969,9 +1021,9 @@ run_partition_execute() {
# a failure names the step that broke rather than surfacing later as
# "protected mode: /mnt is not a mountpoint".
mountpoint -q /mnt ||
disk_abort_hook "Target /mnt is not mounted; not starting the installer"
disk_abort_hook "$(t partitions.targetUnmounted)"
mountpoint -q "/mnt$esp_mount_in_target" ||
disk_abort_hook "ESP is not mounted at /mnt$esp_mount_in_target"
disk_abort_hook "$(t partitions.espUnmounted "/mnt$esp_mount_in_target")"
fi

local luks_uuid_json="null" luks_uuid
Expand Down Expand Up @@ -1254,17 +1306,41 @@ if [[ ${1:-} == "--oem" ]]; then
defer_provisioning=true
fi

# Let the live VT reach its settled width before the first screen so the logo
# isn't measured against the transient 80-column boot console.
wait_for_stable_terminal
i18n_console_font "$(tty 2>/dev/null)"
# Inside kmscon, carry on from where the console run handed over.
resume_stage=""
if [[ -r $KMSCON_RESUME ]]; then
# shellcheck disable=SC1090
source "$KMSCON_RESUME"
rm -f "$KMSCON_RESUME"
# Tells .automated_script.sh that kmscon got this far; a resume file left
# without it means kmscon failed, and the answers carry on in English.
touch "$(dirname "$KMSCON_RESUME")/kmscon-started"
# Back on the console after kmscon failed: the layout picked in kmscon was
# never loaded here, and the password ahead must be typed under it.
if [[ ${OMARCHY_ISO_KMSCON:-} != 1 && -n ${keyboard:-} && $(tty 2>/dev/null) == "/dev/tty"* ]]; then
loadkeys "$keyboard" 2>/dev/null
fi
i18n_load "$language"
set_form_language
fi

if [[ -z $resume_stage ]]; then
# Let the live VT reach its settled width before the first screen so the logo
# isn't measured against the transient 80-column boot console.
wait_for_stable_terminal
i18n_console_font "$(tty 2>/dev/null)"

if ! $oem_install; then
greeter
language_form
if ! $oem_install; then
greeter
language_form
fi

$defer_provisioning || kmscon_for_language
fi

$defer_provisioning || keyboard_form
if [[ -z $resume_stage || $resume_stage == keyboard ]]; then
$defer_provisioning || keyboard_form
fi

# Normal install: keyboard (loaded above, so the LUKS passphrase is typed under
# the right layout) → user → disk → install mode. The user step can unwind to
Expand Down Expand Up @@ -1327,7 +1403,7 @@ if [[ $install_target == "free_space" ]]; then
# terminal while the hash is still running, so a wait on a slow medium
# shows movement instead of a frozen step header.)
if [[ ${1:-} != "dry" ]]; then
step "Verifying the install medium"
step "$(t verify.title)"
if ! verify_error=$(OMARCHY_VERIFY_PROGRESS=/dev/tty OMARCHY_VERIFY_PROGRESS_INDENT="$PADDING_LEFT" \
omarchy-wait-root-image-verify 2>&1 1>/dev/null); then
abort "$(head -1 <<<"$verify_error")"
Expand Down
8 changes: 8 additions & 0 deletions configs/airootfs/root/customize_airootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ fi
rm -rf /usr/share/doc /usr/share/man /usr/share/info /usr/share/gtk-doc /usr/share/gir-1.0 /usr/include
find /usr/share/locale -mindepth 1 -maxdepth 1 ! -name 'en*' ! -name locale.alias -exec rm -rf {} +

# kmscon draws the CJK installer with one face: Noto Sans Mono CJK, which lives
# in the Regular collection. The other weights and the serif set are ~280 MB of
# live root nobody sees.
if [[ -d /usr/share/fonts/noto-cjk ]]; then
find /usr/share/fonts/noto-cjk -type f ! -name NotoSansCJK-Regular.ttc -delete
fc-cache -f >/dev/null 2>&1 || true
fi

mirror=/var/cache/omarchy/mirror/offline
shipped_list=/usr/share/omarchy-iso/offline-mirror.shipped

Expand Down
28 changes: 20 additions & 8 deletions configs/airootfs/usr/local/bin/omarchy-install-dashboard
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ left_padding() {
visible_len() {
local text="$1"
text="$(printf '%b' "$text" | sed -E $'s/\x1b\\[[0-9;?]*[A-Za-z]//g')"
printf '%s' "${#text}"
display_width "$text"
}

blank_line() { printf '\r%s\n' "$CLEAR_LINE"; }
Expand Down Expand Up @@ -524,9 +524,9 @@ render_finish() {
# actually happened, so a failed one withdraws the offer instead of
# printing a promise the machine is not keeping.
if [[ $TARGET_RELEASED == yes ]]; then
center "${DIM}You can now remove the install medium${RESET}" "$CONTENT_WIDTH"
center "${DIM}$(t finish.removeMedium)${RESET}" "$CONTENT_WIDTH"
else
center "${DIM}Leave the install medium in until the reboot completes${RESET}" "$CONTENT_WIDTH"
center "${DIM}$(t finish.keepMedium)${RESET}" "$CONTENT_WIDTH"
fi
} >"$TTY_PATH"

Expand Down Expand Up @@ -600,7 +600,9 @@ warm_reboot_path() {
# render_finish, so the logo effect (up to 8s of it), the timeout in front
# of it, the stty that sizes the prompt, and the button gum paints are all
# still ahead of the moment the user is invited to pull the stick.
for binary in systemctl ttfx gum timeout stty; do
# kmscon too when it draws this screen: it repaints from the medium-backed
# live root on every frame of the effect and the button.
for binary in systemctl ttfx gum timeout stty ${OMARCHY_ISO_KMSCON:+kmscon}; do
path=$(command -v "$binary" 2>/dev/null) || continue
cat "$path" >/dev/null 2>&1 || true
while IFS= read -r dep; do
Expand Down Expand Up @@ -651,7 +653,7 @@ reboot_prompt() {

# The button is the label with two columns of padding either side.
label="$(t finish.reboot)"
prompt_pad=$(( ( $(term_cols) - ${#label} - 8 ) / 2 ))
prompt_pad=$(( ( $(term_cols) - $(display_width "$label") - 8 ) / 2 ))
(( prompt_pad < 0 )) && prompt_pad=0
gum confirm \
--padding "0 0 0 $prompt_pad" \
Expand All @@ -662,10 +664,20 @@ reboot_prompt() {
"" <"$TTY_PATH" >"$TTY_PATH" 2>&1
}

# Cut to width columns, not characters: a CJK character takes two.
truncate_for_width() {
local text="$1" width="$2"
if (( ${#text} > width )); then
printf '%s…' "${text:0:$((width - 1))}"
local text="$1" width="$2" cut columns
(( width < 1 )) && width=1
if (( $(display_width "$text") > width )); then
# A character takes at most two columns, so dropping half the excess never
# cuts too much, and a couple of passes reach the width.
cut=${text:0:$((width - 1))}
columns=$(display_width "$cut")
while (( columns > width - 1 )); do
cut=${cut:0:$((${#cut} - (columns - width + 2) / 2))}
columns=$(display_width "$cut")
done
printf '%s…' "$cut"
else
printf '%s' "$text"
fi
Expand Down
Loading
Loading