diff --git a/bin/omarchy-menu-timezone b/bin/omarchy-menu-timezone index 1c95a1ba799..d642442ca44 100755 --- a/bin/omarchy-menu-timezone +++ b/bin/omarchy-menu-timezone @@ -6,7 +6,13 @@ set -e -timezone=$(timedatectl list-timezones | omarchy-menu-select "Set timezone" -- --width 520 --maxheight 520) || exit 1 +# `timedatectl list-timezones` builds its list from tzdata.zi, which carries the +# backward-compatibility links alongside the zones they point at, so the picker +# offered Asia/Ashkhabad right under Asia/Ashgabat. zone.tab is one row per +# country per zone and holds none of those obsolete aliases; UTC is not in it. +timezones=$({ echo UTC; awk '!/^#/ && NF { print $3 }' /usr/share/zoneinfo/zone.tab; } | sort) + +timezone=$(omarchy-menu-select "Set timezone" -- --width 520 --maxheight 520 <<<"$timezones") || exit 1 sudo timedatectl set-timezone "$timezone" omarchy-shell -q omarchy.clock refresh omarchy-notification-send "Timezone is now set to $timezone" diff --git a/install/provisioning/setup-form.sh b/install/provisioning/setup-form.sh index f4265d1ddec..55ca4dfe522 100644 --- a/install/provisioning/setup-form.sh +++ b/install/provisioning/setup-form.sh @@ -166,6 +166,14 @@ omarchy_prompt_hostname() { done } +# `timedatectl list-timezones` builds its list from tzdata.zi, which carries the +# backward-compatibility links alongside the zones they point at, so the picker +# offered Asia/Ashkhabad right under Asia/Ashgabat. zone.tab is one row per +# country per zone and holds none of those obsolete aliases; UTC is not in it. +omarchy_timezones() { + { echo UTC; awk '!/^#/ && NF { print $3 }' /usr/share/zoneinfo/zone.tab; } | sort +} + # A fresh machine often hasn't joined a network yet, so the geo guess fails # often; guard it or a `set -e` caller dies before the filter fallback. omarchy_prompt_timezone() { @@ -173,9 +181,9 @@ omarchy_prompt_timezone() { guess=$(tzupdate -p 2>/dev/null) || guess="" if [[ -n $guess ]]; then - timezone=$(timedatectl list-timezones | gum choose --height 10 --selected "$guess" --header "Timezone") && status=0 || status=$? + timezone=$(omarchy_timezones | gum choose --height 10 --selected "$guess" --header "Timezone") && status=0 || status=$? else - timezone=$(timedatectl list-timezones | gum filter --height 10 --header "Timezone") && status=0 || status=$? + timezone=$(omarchy_timezones | gum filter --height 10 --header "Timezone") && status=0 || status=$? fi ((status == 0)) || return $status diff --git a/test/shell.d/setup-form-test.sh b/test/shell.d/setup-form-test.sh index 2b9878eb178..7eada6e97b6 100755 --- a/test/shell.d/setup-form-test.sh +++ b/test/shell.d/setup-form-test.sh @@ -216,6 +216,8 @@ assert_status 0 "timezone prompt accepts the geo guess" [[ $(field timezone) == "Europe/Copenhagen" ]] || fail "timezone prompt keeps the chosen timezone" grep -qF -- '--selected Europe/Copenhagen' "$GUM_ARGS" || fail "timezone prompt preselects the geo guess" grep -qF UTC "$tmp_dir/stdin.1" || fail "timezone prompt offers the system timezone list" +grep -qFx Asia/Ashgabat "$tmp_dir/stdin.1" || fail "timezone prompt offers the canonical zone" +! grep -qFx Asia/Ashkhabad "$tmp_dir/stdin.1" || fail "timezone prompt drops tzdata backward-compatibility aliases" pass "timezone prompt preselects the geo guess when one is available" # An unnetworked first boot has no guess, and the fallback has to survive `set -e` diff --git a/test/shell.d/timezone-test.sh b/test/shell.d/timezone-test.sh index dc4a0263b53..54d72284aaf 100644 --- a/test/shell.d/timezone-test.sh +++ b/test/shell.d/timezone-test.sh @@ -19,6 +19,12 @@ grep -F '%wheel ALL=(root) NOPASSWD: /usr/bin/timedatectl ^set-timezone [A-Za-z0 grep -F 'sudo timedatectl set-timezone "$timezone"' "$timezone_menu" >/dev/null || fail "timezone menu uses the passwordless sudoers timedatectl rule" +grep -F '/usr/share/zoneinfo/zone.tab' "$timezone_menu" >/dev/null || + fail "timezone menu lists zones from zone.tab" + +! grep -F 'timedatectl list-timezones |' "$timezone_menu" >/dev/null || + fail "timezone menu does not list tzdata backward-compatibility aliases" + ! grep -F 'pkexec timedatectl set-timezone "$timezone"' "$timezone_menu" >/dev/null || fail "timezone menu does not wrap timedatectl in pkexec"