Fix current theme state migration
This commit is contained in:
@@ -1,6 +1,32 @@
|
||||
-- Hyprland bootstrap for Omarchy's Lua module path.
|
||||
|
||||
local home = os.getenv("HOME")
|
||||
local reload_prefixes = {
|
||||
"default.hypr",
|
||||
"hypr",
|
||||
"omarchy.current.theme",
|
||||
}
|
||||
|
||||
local function should_reload_module(module)
|
||||
for _, prefix in ipairs(reload_prefixes) do
|
||||
if module == prefix or module:sub(1, #prefix + 1) == prefix .. "." then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
local modules_to_reload = {}
|
||||
for module in pairs(package.loaded) do
|
||||
if should_reload_module(module) then
|
||||
table.insert(modules_to_reload, module)
|
||||
end
|
||||
end
|
||||
|
||||
for _, module in ipairs(modules_to_reload) do
|
||||
package.loaded[module] = nil
|
||||
end
|
||||
|
||||
-- Load generated state from ~/.local/state, user modules from ~/.config, and
|
||||
-- Omarchy defaults from $OMARCHY_PATH.
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
echo "Update Hyprland Lua entrypoint to load Omarchy bootstrap"
|
||||
|
||||
hyprland_config="$HOME/.config/hypr/hyprland.lua"
|
||||
|
||||
if [[ -f $hyprland_config ]] && ! grep -Fq '/default/hypr/bootstrap.lua' "$hyprland_config"; then
|
||||
tmp=$(mktemp)
|
||||
|
||||
awk '
|
||||
BEGIN {
|
||||
replaced = 0
|
||||
}
|
||||
|
||||
!replaced && $0 == "-- Load user modules from ~/.config and Omarchy defaults from $OMARCHY_PATH." {
|
||||
comment = $0
|
||||
got_next = getline next_line
|
||||
if (got_next > 0 && next_line == "package.path = os.getenv(\"HOME\")") {
|
||||
print "-- Omarchy'\''s bootstrap keeps path setup out of this user config."
|
||||
print "dofile((os.getenv(\"OMARCHY_PATH\") or \"/usr/share/omarchy\") .. \"/default/hypr/bootstrap.lua\")"
|
||||
replaced = 1
|
||||
|
||||
while ((getline line) > 0) {
|
||||
if (line ~ /^[[:space:]]*\.\. package\.path$/) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
next
|
||||
}
|
||||
|
||||
print comment
|
||||
if (got_next > 0) {
|
||||
print next_line
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
{ print }
|
||||
' "$hyprland_config" >"$tmp"
|
||||
|
||||
mv "$tmp" "$hyprland_config"
|
||||
fi
|
||||
@@ -423,6 +423,30 @@ for nvim_legacy_target in \
|
||||
done
|
||||
pass "nvim theme migration relinks current theme"
|
||||
|
||||
HYPR_MIGRATION_TMPDIR=$(mktemp -d)
|
||||
mkdir -p "$HYPR_MIGRATION_TMPDIR/.config/hypr"
|
||||
cat >"$HYPR_MIGRATION_TMPDIR/.config/hypr/hyprland.lua" <<'LUA'
|
||||
-- Learn how to configure Hyprland: https://wiki.hypr.land/Configuring/Start/
|
||||
|
||||
-- Load user modules from ~/.config and Omarchy defaults from $OMARCHY_PATH.
|
||||
package.path = os.getenv("HOME")
|
||||
.. "/.config/?.lua;"
|
||||
.. (os.getenv("OMARCHY_PATH") or (os.getenv("HOME") .. "/.local/share/omarchy"))
|
||||
.. "/?.lua;"
|
||||
.. package.path
|
||||
|
||||
-- All Omarchy default setups
|
||||
require("default.hypr.omarchy")
|
||||
|
||||
-- Add any other personal Hyprland configuration below.
|
||||
o.window("Example", { workspace = "1" })
|
||||
LUA
|
||||
HOME="$HYPR_MIGRATION_TMPDIR" bash -euo pipefail "$ROOT/migrations/1781063758.sh" >/dev/null
|
||||
grep -Fq 'dofile((os.getenv("OMARCHY_PATH") or "/usr/share/omarchy") .. "/default/hypr/bootstrap.lua")' "$HYPR_MIGRATION_TMPDIR/.config/hypr/hyprland.lua" || fail "hyprland bootstrap migration adds bootstrap"
|
||||
! grep -Fq 'package.path = os.getenv("HOME")' "$HYPR_MIGRATION_TMPDIR/.config/hypr/hyprland.lua" || fail "hyprland bootstrap migration removes legacy path block"
|
||||
grep -Fq 'o.window("Example", { workspace = "1" })' "$HYPR_MIGRATION_TMPDIR/.config/hypr/hyprland.lua" || fail "hyprland bootstrap migration preserves custom config"
|
||||
pass "hyprland bootstrap migration updates stale user entrypoint"
|
||||
|
||||
cp "$NEXT_THEME/colors.toml" "$CURRENT_THEME/colors.toml"
|
||||
cp "$NEXT_THEME/vscode-theme.json" "$CURRENT_THEME/vscode-theme.json"
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
export PATH="$ROOT/bin:$PATH"
|
||||
|
||||
require_command jq
|
||||
require_command lua
|
||||
require_command python3
|
||||
|
||||
jq empty "$ROOT/config/omarchy/shell.json"
|
||||
@@ -152,6 +153,23 @@ grep -F 'package.path = home' "$ROOT/default/hypr/bootstrap.lua" >/dev/null
|
||||
grep -F '/.local/state/?.lua;' "$ROOT/default/hypr/bootstrap.lua" >/dev/null
|
||||
pass "Hyprland user entrypoint keeps package and state path bootstrap in defaults"
|
||||
|
||||
OMARCHY_PATH="$ROOT" lua <<'LUA'
|
||||
package.loaded["default.hypr.omarchy"] = true
|
||||
package.loaded["default.hypr.require_optional"] = true
|
||||
package.loaded["hypr.looknfeel"] = true
|
||||
package.loaded["omarchy.current.theme.hyprland"] = true
|
||||
package.loaded["unrelated.module"] = true
|
||||
|
||||
dofile(os.getenv("OMARCHY_PATH") .. "/default/hypr/bootstrap.lua")
|
||||
|
||||
assert(package.loaded["default.hypr.omarchy"] == nil)
|
||||
assert(package.loaded["default.hypr.require_optional"] == nil)
|
||||
assert(package.loaded["hypr.looknfeel"] == nil)
|
||||
assert(package.loaded["omarchy.current.theme.hyprland"] == nil)
|
||||
assert(package.loaded["unrelated.module"] == true)
|
||||
LUA
|
||||
pass "Hyprland bootstrap reloads cached Omarchy config modules"
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
mkdir -p "$TMPDIR/home/.config/omarchy"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user