Skip to content
Merged
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
11 changes: 11 additions & 0 deletions packages/omamobile-firstboot/bin/omamobile-firstboot
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,17 @@ s_user_setup() {
uid=$(id -u "$U") home=$ROOT$(home_of "$U")
systemctl start "user@$uid.service" || echo " no user manager; continuing without it"
as_user omarchy-provision-user --force --first-install || { echo " omarchy-provision-user failed"; failed=1; }
# git's name and email. Omarchy 4.0's user setup wrote them from the two
# variables as_user passes; Omarchy 4.5's writes only the Compose shortcuts
# (its git setup is a command the owner runs). Written here, so the
# installer's answers reach git under either; a blank one stays unset, and
# a failure is said but doesn't fail the first boot.
if [[ -n ${C[FULL_NAME]//[[:space:]]/} ]]; then
as_user git config --global user.name "${C[FULL_NAME]}" || echo " git's user.name could not be set"
fi
if [[ -n ${C[EMAIL]//[[:space:]]/} ]]; then
as_user git config --global user.email "${C[EMAIL]}" || echo " git's user.email could not be set"
fi
if command -v omamobile-setup-user >/dev/null; then
as_user omamobile-setup-user || { echo " omamobile-setup-user failed"; failed=1; }
fi
Expand Down
9 changes: 9 additions & 0 deletions packages/omamobile-firstboot/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ grep -qx pin "$R/home/alice/.config/omamobile/credential" || fail "the credentia
[[ -e $R/home/alice/.local/state/omarchy/toggles/lock-on-start ]] || fail "the phone locks after boot"
grep -qF "$PSK" "$R/var/log/omamobile/firstboot.log" "$t/run.out" && fail "the log never has the passphrase"
grep -qF "$HASH" "$R/var/log/omamobile/firstboot.log" "$t/run.out" && fail "the log never has the hash"
grep -c ' git config --global user.name Alice Example$' "$CALLS" >/dev/null || fail "git gets the owner's name, whatever Omarchy's user setup does"
grep -c ' git config --global user.email alice@example.org$' "$CALLS" >/dev/null || fail "git gets the owner's email"
pass "a run sets everything up and deletes the conf"

[[ -e $R/ran-other-leaf ]] || fail "Omarchy's setup leaves run"
Expand All @@ -200,6 +202,13 @@ grep -q '^usermod -aG wheel,audio,video,input' "$CALLS" || fail "a second run up
[[ $(grep -cxF "$KEY" "$R/home/alice/.ssh/authorized_keys") == 1 ]] || fail "a second run doesn't duplicate the key"
pass "running again is safe"

# The name and email are optional: without them git is left alone
: > "$CALLS"
good | sed '/^WIFI_/d; /^FULL_NAME=/d; /^EMAIL=/d' > "$R/etc/omamobile/firstboot.conf"
run || { cat "$t/run.out"; fail "a run without a name and email succeeds"; }
grep -c ' git config ' "$CALLS" >/dev/null && fail "without a name and email git's config is not written"
pass "the installer's name and email reach git; without them git is left alone"

: > "$CALLS"
rm "$R/usr/share/pacman/keyrings/"*.gpg
export TEST_NOW=1
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-firstboot/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.3
0.1.4
9 changes: 7 additions & 2 deletions packages/omamobile-omarchy/bin/omamobile-update
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ directory of stand-ins first on PATH (/usr/lib/omamobile-omarchy/update-bin):
root), omarchy-update-aur-pkgs (no AUR builds on the phone),
omarchy-update-orphan-pkgs (listed, never removed),
omarchy-update-restart (no gum, no false "kernel updated":
a restart is asked for when omamobile-boot-update wrote slot B),
a restart is asked for when omamobile-boot-update wrote slot B;
Omarchy 4.5 runs it as two halves, --services-only then
--reboot-only, and each does only its half),
omarchy-update-boot (4.5's boot verification is for a
computer's boot files; slot B's images are checked by
omamobile-boot-update),
omarchy-migrate (boot-related migrations held), sudo
(non-interactive from the sheet)

Expand Down Expand Up @@ -720,7 +725,7 @@ def run(args):
print()
print("omamobile-update: %s" % result["message"])
if result["needs_reboot"]:
print("Restart the phone to finish (%s): omarchy-system-reboot" % "; ".join(result["reasons"]))
print("Restart the phone to finish (%s): omarchy reboot" % "; ".join(result["reasons"]))
for h in result["held"]:
print("Held migration %s (%s): omamobile-update run-migration %s" % (h[0], h[1], h[0]))
return code
Expand Down
1 change: 1 addition & 0 deletions packages/omamobile-omarchy/lib/update-bin/omarchy-migrate
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mobile_pattern='omarchy-hyprland-titlebars|owedvideo|fcitx|omarchy-apply-lock|/e
mobile_hold_reason() {
case $1 in
1791403310.sh) echo 'installs titlebars pinned to a different Hyprland build' ;;
1790042972.sh) echo 'adds a world clock to the bar (the phone has its own status bar)' ;;
1789764927.sh) echo 'starts owedvideo (unreviewed mobile video pipeline)' ;;
1791367434.sh) echo 'replaces input method with Fcitx defaults' ;;
1791125650.sh) echo 'changes fprintd resume/stop lifecycle (preserve mobile PAM/claim policy)' ;;
Expand Down
15 changes: 15 additions & 0 deletions packages/omamobile-omarchy/lib/update-bin/omarchy-update-boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# Omarchy Mobile (on PATH only during omamobile-update): Omarchy 4.5's boot
# verification, which asks the platform's boot package whether the files the
# update left will boot (a UKI, limine, an initramfs on a computer). A phone
# has none of those: its boot images are slot B's, written and read back by
# linux-omamobile's hook (omamobile-boot-update), and a write that was
# refused or failed is reported by the restart step that follows, as a
# warning with the command that finishes it. So there is nothing to verify
# here, and nothing here may fail the update or ask for sudo.
if (( $# )); then
echo "Usage: omarchy-update-boot" >&2
exit 2
fi
exit 0
55 changes: 41 additions & 14 deletions packages/omamobile-omarchy/lib/update-bin/omarchy-update-restart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,42 @@
# wrote slot B during this update; a kernel package it could not write is a
# warning. Services Omarchy marked are restarted and the shell too, as on a
# desktop. Nothing reboots here: the update sheet offers the restart.
out=${OMAMOBILE_UPDATE_DIR:-${XDG_RUNTIME_DIR:-/tmp}/omamobile-update}/restart.json
#
# Omarchy 4.5 runs this step twice: --services-only after the migrations
# (the marked services and the shell), then --reboot-only at the very end
# (whether a restart is needed). Each does its half here too, so services
# and the shell restart once; a service that failed to restart in the first
# half is kept for the second's warnings. Without an argument (Omarchy 4.0)
# it does both, as before.
dir=${OMAMOBILE_UPDATE_DIR:-${XDG_RUNTIME_DIR:-/tmp}/omamobile-update}
out=$dir/restart.json
kept=$dir/restart-warnings
reasons=() warnings=()
services=1 verdict=1
case ${1:-} in
--services-only) verdict=0 ;;
--reboot-only) services=0 ;;
"") ;;
*) echo "omarchy-update-restart (phone): unknown option $1" >&2; exit 2 ;;
esac

if (( services )); then
mkdir -p "$dir"
: > "$kept"
for file in "$HOME"/.local/state/omarchy/restart-*-required; do
[[ -f $file ]] || continue
name=${file##*/}
service=${name#restart-}
service=${service%-required}
echo "Restarting $service"
omarchy-state clear "$name" || rm -f "$file"
"omarchy-restart-$service" || echo "Restarting $service failed" >> "$kept"
done

echo -e "\e[32m\nRestarting shell\e[0m"
omarchy-restart-shell || true
fi
(( verdict )) || exit 0

modules=${OMAMOBILE_MODULES_DIR:-/usr/lib/modules}/$(uname -r)
[[ -d $modules ]] || warnings+=("No modules for the running kernel in $modules")
Expand Down Expand Up @@ -53,20 +87,13 @@ if [[ -n $pid ]] && [[ $(readlink "/proc/$pid/exe" 2>/dev/null) == *"(deleted)"*
reasons+=("Hyprland was updated")
fi

for file in "$HOME"/.local/state/omarchy/restart-*-required; do
[[ -f $file ]] || continue
name=${file##*/}
service=${name#restart-}
service=${service%-required}
echo "Restarting $service"
omarchy-state clear "$name" || rm -f "$file"
"omarchy-restart-$service" || warnings+=("Restarting $service failed")
done

echo -e "\e[32m\nRestarting shell\e[0m"
omarchy-restart-shell || true
if [[ -s $kept ]]; then
mapfile -t failed < "$kept"
warnings+=("${failed[@]}")
fi
rm -f "$kept"

mkdir -p "${out%/*}"
mkdir -p "$dir"
python3 -I - "$out" "${#reasons[@]}" "${reasons[@]}" "${warnings[@]}" <<'PY'
import json, sys
out, n = sys.argv[1], int(sys.argv[2])
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-omarchy/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for f in usr/bin/omamobile-omarchy-patches usr/bin/omamobile-update usr/lib/omam
[[ -e $t/stage/$f ]] || fail "not staged: $f"
done
for f in omarchy-snapshot omarchy-update-aur-pkgs omarchy-update-orphan-pkgs omarchy-update-confirm \
omarchy-update-firmware omarchy-update-restart omarchy-migrate sudo; do
omarchy-update-firmware omarchy-update-restart omarchy-update-boot omarchy-migrate sudo; do
[[ -x $t/stage/usr/lib/omamobile-omarchy/update-bin/$f ]] || fail "stand-in not staged: $f"
done
[[ $(ls "$t/stage/usr/share/omamobile/omarchy/patches" | wc -l) == $(ls patches/*.patch | wc -l) ]] || fail "every patch staged"
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-omarchy/test/migration-mobile-holds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import tempfile

PACKAGE = Path(__file__).resolve().parent.parent
NAMED = ['1789764927', '1791367434', '1791125650', '1791403310']
NAMED = ['1789764927', '1791367434', '1791125650', '1791403310', '1790042972']
# Reviewed and released: Omarchy's own file, so a change of its text that
# would match a hold pattern shows here
RELEASED = ['1792648436']
Expand Down
32 changes: 30 additions & 2 deletions packages/omamobile-omarchy/test/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ cat >"$fake/omarchy-update" <<EOF
#!/bin/bash
echo "omarchy-update \$* OMARCHY_UPDATE_LOGGED=\$OMARCHY_UPDATE_LOGGED OMAMOBILE_UPDATE=\$OMAMOBILE_UPDATE" >>"$calls"
echo "omarchy-update OMARCHY_PATH=\${OMARCHY_PATH-unset}" >>"$calls"
for c in omarchy-snapshot omarchy-update-aur-pkgs omarchy-update-orphan-pkgs omarchy-migrate omarchy-update-restart sudo; do
for c in omarchy-snapshot omarchy-update-aur-pkgs omarchy-update-orphan-pkgs omarchy-migrate omarchy-update-restart omarchy-update-boot sudo; do
echo "resolve \$c \$(command -v \$c)" >>"$calls"
done
omarchy-snapshot create; echo "snapshot rc \$?" >>"$calls"
Expand Down Expand Up @@ -350,7 +350,7 @@ ok "the PIN reached sudo -S on stdin, never argv" 'grep -c "^sudo -S -p -v$" "$
ok "no password file left behind" '[[ ! -e $XDG_RUNTIME_DIR/omamobile-update/auth ]]'
ok "the unit runs as omamobile-update" 'grep -c -- "--unit=omamobile-update" "$calls" >/dev/null'
ok "omarchy-update -y, unlogged (script is ours), OMAMOBILE_UPDATE=1" 'grep -c "^omarchy-update -y OMARCHY_UPDATE_LOGGED=1 OMAMOBILE_UPDATE=1" "$calls" >/dev/null'
for c in omarchy-snapshot omarchy-update-aur-pkgs omarchy-update-orphan-pkgs omarchy-migrate omarchy-update-restart sudo; do
for c in omarchy-snapshot omarchy-update-aur-pkgs omarchy-update-orphan-pkgs omarchy-migrate omarchy-update-restart omarchy-update-boot sudo; do
ok "stand-in on PATH: $c" 'grep -c "^resolve $c $PKG/lib/update-bin/$c$" "$calls" >/dev/null'
done
ok "snapshot: skipped with 127, real Snapper never called" 'grep -c "^snapshot rc 127$" "$calls" >/dev/null && ! grep -c real-snapshot "$calls" >/dev/null'
Expand Down Expand Up @@ -445,6 +445,34 @@ printf '{"result": "skipped", "release": "", "message": "AUTO_WRITE is off", "ti
out=$(rs $((now - 5)))
ok "restart: a skipped write (development phone) asks for nothing" 'python3 -c "import json,sys; d=json.loads(sys.argv[1]); assert not d[\"needs_reboot\"] and not any(\"kernel\" in w for w in d[\"warnings\"]), d" "$out"'

# Omarchy 4.5 runs the restart step in two halves. The first restarts the
# marked services and the shell and decides nothing; the second decides and
# restarts nothing, and still knows which service failed to restart
half() { OMAMOBILE_UPDATE_DIR=$t/rs OMAMOBILE_BOOT_UPDATE_STATUS=$t/bu.json OMAMOBILE_UPDATE_STARTED=$((now - 5)) bash lib/update-bin/omarchy-update-restart "$@" >/dev/null 2>&1; }
printf '{"result": "written", "release": "7.3.0-rc6-omamobile-g0123456789ab", "kernel_changed": true, "message": "x", "time": %d}\n' "$now" >"$t/bu.json"
mkdir -p "$HOME/.local/state/omarchy"
touch "$HOME/.local/state/omarchy/restart-waybar-required" "$HOME/.local/state/omarchy/restart-broken-required"
rm -rf "$t/rs"; : >"$calls"
half --services-only
ok "restart, first half: the marked service and the shell restart, once each" '[[ $(grep -c "^restart-waybar$" "$calls") == 1 && $(grep -c "^restart-shell$" "$calls") == 1 ]]'
ok "restart, first half: no verdict yet" '[[ ! -e $t/rs/restart.json ]]'
: >"$calls"
half --reboot-only
ok "restart, second half: nothing restarts again" '! grep -c "^restart-" "$calls" >/dev/null'
ok "restart, second half: the verdict, with the first half's failed service as a warning" 'python3 -c "import json; d=json.load(open(\"$t/rs/restart.json\")); assert d[\"needs_reboot\"] and \"kernel was updated\" in d[\"reasons\"][0] and d[\"warnings\"] == [\"Restarting broken failed\"], d"'
half --reboot-only
ok "restart, second half alone: no warning left over from an earlier run" 'python3 -c "import json; d=json.load(open(\"$t/rs/restart.json\")); assert d[\"warnings\"] == [], d"'
rc=0; half --sideways || rc=$?
ok "restart: an option it doesn't know is refused" '[[ $rc == 2 ]]'
: >"$calls"; rm -rf "$t/rs"
half
ok "restart, no argument (Omarchy 4.0): both halves in one run" 'grep -c "^restart-shell$" "$calls" >/dev/null && [[ -e $t/rs/restart.json ]]'
rc=0; out=$(bash lib/update-bin/omarchy-update-boot 2>&1) || rc=$?
ok "boot check (Omarchy 4.5): the phone's stand-in passes, silently, without sudo" '[[ $rc == 0 && -z $out ]]'
rc=0; bash lib/update-bin/omarchy-update-boot extra 2>/dev/null || rc=$?
ok "boot check: an argument is refused as Omarchy's is" '[[ $rc == 2 ]]'
printf 'omarchy 4.0.5-1\nmesa 26.1-1\n' >"$t/plan"

# Low battery and wrong repository order: refused before the PIN is used
battery 12 Discharging 0
rm -f "$t/sudo-ok"; : >"$calls"
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-omarchy/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.42
0.1.43
31 changes: 27 additions & 4 deletions packages/omamobile-shell/bin/omamobile-onboarding
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ has_identity() {
[[ -n $(git config --global user.name) && -n $(git config --global user.email) ]]
}

# The owner's name and email, for git and the Compose shortcuts. Omarchy 4.5
# has one command for both (omarchy-setup-git, which sets what it is given
# and asks nothing); Omarchy 4.0 had two install scripts, of which 4.5 kept
# only the Compose one. A blank value is left as it was, as before.
# OMAMOBILE_SETUP_GIT names another command, for the tests.
save_identity() {
local name=$1 email=$2 setup=${OMAMOBILE_SETUP_GIT:-omarchy-setup-git} args=()
[[ -z ${name//[[:space:]]/} ]] || args+=(--name "$name")
[[ -z ${email//[[:space:]]/} ]] || args+=(--email "$email")
(( ${#args[@]} )) || return 0
if command -v "$setup" >/dev/null 2>&1; then
"$setup" "${args[@]}"
return
fi
[[ -z ${name//[[:space:]]/} ]] || git config --global user.name "$name" || return 1
[[ -z ${email//[[:space:]]/} ]] || git config --global user.email "$email" || return 1
if [[ -f $omarchy_path/install/user/xcompose.sh ]]; then
OMARCHY_USER_NAME=$name OMARCHY_USER_EMAIL=$email bash "$omarchy_path/install/user/xcompose.sh" || return 1
fi
}

has_pin() {
! printf '' | unix_chkpwd "$USER" nullok 2>/dev/null
}
Expand Down Expand Up @@ -162,10 +183,12 @@ case "${1:-}" in
echo
name=$(gum input --header "Your name" --placeholder "Ada Lovelace" --value "$(git config --global user.name)")
email=$(gum input --header "Your email" --placeholder "ada@example.com" --value "$(git config --global user.email)")
if [[ -n $name || -n $email ]]; then
OMARCHY_USER_NAME=$name OMARCHY_USER_EMAIL=$email bash "$omarchy_path/install/user/git.sh"
OMARCHY_USER_NAME=$name OMARCHY_USER_EMAIL=$email bash "$omarchy_path/install/user/xcompose.sh"
echo "Saved."
if [[ -n ${name//[[:space:]]/} || -n ${email//[[:space:]]/} ]]; then
if save_identity "$name" "$email"; then
echo "Saved."
else
echo "Your name and email could not be saved. Set them later with: omamobile-onboarding"
fi
fi
echo
if has_pin; then
Expand Down
34 changes: 34 additions & 0 deletions packages/omamobile-shell/bin/omamobile-reboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: MIT
# omamobile-reboot: restart the phone the way Omarchy does (an on-screen
# note, the open apps closed, then systemd's reboot, which stops every unit:
# the modem gets its clean stop).
#
# The shell's Restart buttons (the update sheet, the mobile network page) run
# this, so they don't carry the name of Omarchy's command, which changed:
# Omarchy 4.0 has omarchy-system-reboot, Omarchy 4.5 has "omarchy-system
# reboot". With neither, systemd is asked directly.
#
# omamobile-reboot
# omamobile-reboot --help
#
# OMAMOBILE_SYSTEMCTL names another systemctl, for the tests.

case ${1:-} in
-h|--help)
sed -n '3,13s/^# \{0,1\}//p' "$0"
exit 0
;;
"") ;;
*)
echo "omamobile-reboot: unknown option $1" >&2
exit 2
;;
esac

if command -v omarchy-system >/dev/null 2>&1; then
exec omarchy-system reboot
elif command -v omarchy-system-reboot >/dev/null 2>&1; then
exec omarchy-system-reboot
fi
exec "${OMAMOBILE_SYSTEMCTL:-systemctl}" reboot --no-wall
30 changes: 30 additions & 0 deletions packages/omamobile-shell/bin/omamobile-setup-user
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,17 @@ if command -v "${OMAMOBILE_VOXTYPE:-voxtype}" >/dev/null && [[ -f $voxmodels/ggm
echo "omamobile-setup-user: could not link ${model##*/}" >&2
done
fi
# Omarchy 4.5 asks which dictation backend is the default
# (~/.config/omarchy/defaults/dictation) and ships two; its migration
# answers "voxtype" for someone who had Voxtype before, and a new user on a
# 4.5 image has no answer. The phone's is Voxtype, the one the voice bar
# drives, unless the owner has chosen. Omarchy 4.0 never reads the file.
dictation_default=~/.config/omarchy/defaults/dictation
if omarchy-done check omamobile-voxtype-setup && [[ ! -e $dictation_default ]] &&
omarchy-done ensure omamobile-dictation-default; then
mkdir -p "${dictation_default%/*}" && printf 'voxtype\n' >"$dictation_default" ||
echo "omamobile-setup-user: could not record Voxtype as the dictation default" >&2
fi
if omarchy-done check omamobile-voxtype-setup && ! omarchy-done check omamobile-voxtype-enabled; then
if systemctl --user enable voxtype.service; then
omarchy-done mark omamobile-voxtype-enabled
Expand Down Expand Up @@ -644,6 +655,25 @@ menu_hide "no keyboard to learn bindings for" learn.keybindings learn.tmux-keybi
menu_hide "the phone's status bar stays at the top" \
style.bar.position.left style.bar.position.right style.bar.position.bottom \
trigger.toggle.top-bar trigger.toggle.one-window-ratio trigger.toggle.workspace-layout
# The same rows under the ids Omarchy 4.5 gave them when Style became
# Appearance (a row the installed Omarchy doesn't have is an entry nothing
# reads), and its disk-unlock row, which the once-only block above hid under
# its 4.0 id.
menu_hide "the phone's status bar stays at the top (Omarchy 4.5's ids)" \
appearance.top-bar.position.left appearance.top-bar.position.right appearance.top-bar.position.bottom \
appearance.top-bar.hide appearance.top-bar.show \
appearance.windows.one-window-ratio-on appearance.windows.one-window-ratio-off \
appearance.workspace-layout appearance.workspace-layout.dwindle appearance.workspace-layout.scrolling \
appearance.workspace-layout.floating
menu_hide "no disk-unlock screen on the phone (Omarchy 4.5's id)" appearance.unlock
# New in Omarchy 4.5: a dock for floating workspaces, which a phone never has
# (one maximized app per workspace), and a kernel update that would install a
# kernel the phone can't boot (the phone's kernel is linux-omamobile, written
# to slot B by its own hook).
menu_hide "no dock and no other kernel on a phone (Omarchy 4.5)" \
appearance.dock appearance.dock.always-on appearance.dock.autohide appearance.dock.position \
appearance.dock.position.bottom appearance.dock.position.left appearance.dock.position.right appearance.dock.position.top \
update.kernel
menu_hide "x86_64-only installers" \
install.windows install.browser.chrome install.browser.edge \
install.service.dropbox install.service.spotify install.service.nordvpn \
Expand Down
Loading