Preserve user state during theme setup
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
# Setup user theme folder
|
||||
# Setup user theme folder and seed the default only when no theme exists yet.
|
||||
mkdir -p ~/.config/omarchy/themes
|
||||
|
||||
if [[ ${OMARCHY_SETUP_CONTEXT:-runtime} == "iso-chroot" ]]; then
|
||||
OMARCHY_THEME_HEADLESS=1 omarchy-theme-set "Tokyo Night"
|
||||
else
|
||||
omarchy-theme-set "Tokyo Night"
|
||||
if [[ ! -s $HOME/.local/state/omarchy/current/theme.name ]]; then
|
||||
if [[ ${OMARCHY_SETUP_CONTEXT:-runtime} == "iso-chroot" ]]; then
|
||||
OMARCHY_THEME_HEADLESS=1 omarchy-theme-set "Tokyo Night"
|
||||
rm -f ~/.config/chromium/SingletonLock # otherwise archiso owns the Chromium singleton
|
||||
else
|
||||
omarchy-theme-set "Tokyo Night"
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf ~/.config/chromium/SingletonLock
|
||||
omarchy-theme-set-pi --activate
|
||||
|
||||
mkdir -p ~/.config/btop/themes
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname "$0")/base-test.sh"
|
||||
|
||||
test_tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$test_tmp"' EXIT
|
||||
|
||||
mock_bin="$test_tmp/bin"
|
||||
mkdir -p "$mock_bin" "$test_tmp/home/.config/chromium" "$test_tmp/home/.local/state/omarchy/current"
|
||||
|
||||
cat >"$mock_bin/omarchy-theme-set" <<'SH'
|
||||
#!/bin/bash
|
||||
printf '%s\n' "$*" >>"$OMARCHY_TEST_THEME_CALLS"
|
||||
SH
|
||||
chmod +x "$mock_bin/omarchy-theme-set"
|
||||
|
||||
for command in omarchy-theme-set-pi; do
|
||||
cat >"$mock_bin/$command" <<'SH'
|
||||
#!/bin/bash
|
||||
exit 0
|
||||
SH
|
||||
chmod +x "$mock_bin/$command"
|
||||
done
|
||||
|
||||
calls="$test_tmp/theme-calls"
|
||||
touch "$test_tmp/home/.config/chromium/SingletonLock"
|
||||
HOME="$test_tmp/home" PATH="$mock_bin:$PATH" OMARCHY_TEST_THEME_CALLS="$calls" \
|
||||
bash "$ROOT/install/user/theme.sh"
|
||||
grep -Fx 'Tokyo Night' "$calls" >/dev/null || fail "user theme setup seeds Tokyo Night when no theme exists"
|
||||
[[ -f $test_tmp/home/.config/chromium/SingletonLock ]] || fail "runtime user theme setup preserves Chromium's singleton lock"
|
||||
|
||||
: >"$calls"
|
||||
printf 'Solitude\n' >"$test_tmp/home/.local/state/omarchy/current/theme.name"
|
||||
HOME="$test_tmp/home" PATH="$mock_bin:$PATH" OMARCHY_TEST_THEME_CALLS="$calls" \
|
||||
bash "$ROOT/install/user/theme.sh"
|
||||
[[ ! -s $calls ]] || fail "user theme setup preserves an existing theme"
|
||||
|
||||
pass "user theme setup only seeds the default theme once"
|
||||
Reference in New Issue
Block a user