diff options
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rwxr-xr-x | copy.sh | 14 | ||||
| -rw-r--r-- | scripts/lib_copy.sh | 69 | ||||
| -rw-r--r-- | scripts/lib_prompts.sh | 46 |
4 files changed, 133 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 31654169..d57ea5db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,10 @@ ## Updated: +- `copy.sh` + - Defaults to LUA on Fresh Install + - Upgrades and express upgrade now migrate Hyprlang to LUA + - It will also convert UserConfigs/\*.conf to LUA - Moved `qs-hyprview` to `alt - tab` - Won't conflict with `alt - tab` used in applications - `copy.sh` to not overwrite all configs on update @@ -343,6 +343,7 @@ EOF UPGRADE_MODE=0 EXPRESS_MODE=0 +MIGRATE_HYPR_TO_LUA=0 RUN_MODE="" while [[ $# -gt 0 ]]; do @@ -611,6 +612,11 @@ printf "\n%.0s" {1..1} printf "\n%.0s" {1..1} prompt_express_upgrade "$EXPRESS_SUPPORTED" "$LOG" +# Upgrade/express: confirm Hyprlang -> Lua migration (default yes). +if [ "$RUN_MODE" = "upgrade" ] || [ "$RUN_MODE" = "express" ]; then + prompt_lua_migration "$LOG" +fi + set -e # Check if the ${XDG_CONFIG_HOME:-$HOME/.config}/ directory exists @@ -631,6 +637,10 @@ printf "${INFO} - Copying dotfiles ${SKY_BLUE}second${RESET} part\n" copy_phase2 "$LOG" preserve_custom_sddm_configs "$LOG" ensure_lua_keybinds "$LOG" +# Fresh copy defaults to Lua config (Hyprland next release is Lua-only). +if [ "$RUN_MODE" = "install" ]; then + enable_fresh_install_lua_config "$LOG" +fi printf "\\n%.0s" {1..1} # waybar-weather config handling: # - install (fresh copy): always overwrite and prompt for units @@ -815,6 +825,10 @@ printf "\n%.0s" {1..1} restore_hypr_files "$LOG" "$EXPRESS_MODE" restore_runtime_personal_state "$LOG" +# After restores, migrate restored Hyprlang customizations to Lua when approved. +if [ "$RUN_MODE" = "upgrade" ] || [ "$RUN_MODE" = "express" ]; then + migrate_hypr_to_lua_if_needed "$LOG" "${MIGRATE_HYPR_TO_LUA:-0}" || true +fi printf "\n%.0s" {1..1} printf "\n%.0s" {1..1} diff --git a/scripts/lib_copy.sh b/scripts/lib_copy.sh index 0c065ca9..8d5b5887 100644 --- a/scripts/lib_copy.sh +++ b/scripts/lib_copy.sh @@ -142,6 +142,75 @@ copy_phase2() { install_terminal_configs "$log" } +# Fresh install default: enable Hyprland Lua entrypoint (next release is Lua-only). +enable_fresh_install_lua_config() { + local log="${1:-/dev/null}" + local hypr_dir + local src_entry + local base="${DOTFILES_DIR:-.}" + hypr_dir="${XDG_CONFIG_HOME:-$HOME/.config}/hypr" + src_entry="$base/config/hypr/hyprland.lua.disable" + + mkdir -p "$hypr_dir" + + if [ -f "$hypr_dir/hyprland.lua" ]; then + rm -f "$hypr_dir/hyprland.lua.disable" 2>/dev/null || true + echo "${OK:-[OK]} - Fresh install: Hyprland Lua entrypoint already enabled." 2>&1 | tee -a "$log" + return 0 + fi + + if [ -f "$hypr_dir/hyprland.lua.disable" ]; then + mv -f "$hypr_dir/hyprland.lua.disable" "$hypr_dir/hyprland.lua" + echo "${OK:-[OK]} - Fresh install: enabled default Hyprland Lua config (hyprland.lua)." 2>&1 | tee -a "$log" + return 0 + fi + + if [ -f "$src_entry" ]; then + cp -f "$src_entry" "$hypr_dir/hyprland.lua" + echo "${OK:-[OK]} - Fresh install: installed default Hyprland Lua entrypoint from repo template." 2>&1 | tee -a "$log" + return 0 + fi + + echo "${WARN:-[WARN]} - Fresh install: no hyprland.lua template found; left Hyprlang entrypoint as-is." 2>&1 | tee -a "$log" + return 1 +} + +# Run scripts/migrate-hypr-to-lua.sh after upgrade restores when approved. +migrate_hypr_to_lua_if_needed() { + local log="${1:-/dev/null}" + local migrate_flag="${2:-${MIGRATE_HYPR_TO_LUA:-0}}" + local base="${DOTFILES_DIR:-.}" + local migrate_script="$base/scripts/migrate-hypr-to-lua.sh" + local hypr_dir + hypr_dir="${XDG_CONFIG_HOME:-$HOME/.config}/hypr" + + if [ "$migrate_flag" != "1" ]; then + echo "${NOTE:-[NOTE]} - LUA migration skipped by user choice." 2>&1 | tee -a "$log" + return 0 + fi + + if [ ! -x "$migrate_script" ] && [ -f "$migrate_script" ]; then + chmod +x "$migrate_script" 2>/dev/null || true + fi + + if [ ! -f "$migrate_script" ]; then + echo "${ERROR:-[ERROR]} - Migration script not found: $migrate_script" 2>&1 | tee -a "$log" + return 1 + fi + + echo "${INFO:-[INFO]} - Migrating Hyprlang configuration to LUA via migrate-hypr-to-lua.sh..." 2>&1 | tee -a "$log" + if "$migrate_script" --yes 2>&1 | tee -a "$log"; then + echo "${OK:-[OK]} - Hyprland configuration migrated to LUA." 2>&1 | tee -a "$log" + return 0 + fi + + echo "${ERROR:-[ERROR]} - LUA migration failed. Hyprlang config may still be active." 2>&1 | tee -a "$log" + if [ -f "$hypr_dir/hyprland.lua.disable" ] && [ ! -f "$hypr_dir/hyprland.lua" ]; then + echo "${NOTE:-[NOTE]} - Lua entrypoint remains disabled at $hypr_dir/hyprland.lua.disable" 2>&1 | tee -a "$log" + fi + return 1 +} + ensure_lua_keybinds() { local log="$1" local base="${DOTFILES_DIR:-.}" diff --git a/scripts/lib_prompts.sh b/scripts/lib_prompts.sh index bd8d9c75..1bdf4fc7 100644 --- a/scripts/lib_prompts.sh +++ b/scripts/lib_prompts.sh @@ -218,6 +218,52 @@ apply_sddm_12h_format_sequoia() { } +# Confirm Hyprlang -> Lua migration during upgrade/express workflows. +# Sets MIGRATE_HYPR_TO_LUA=1 (default yes) or 0 when the user declines. +prompt_lua_migration() { + local log="${1:-/dev/null}" + local hypr_dir + hypr_dir="${XDG_CONFIG_HOME:-$HOME/.config}/hypr" + + MIGRATE_HYPR_TO_LUA=1 + + # Already on Lua entrypoint: still refresh/migrate overlays after upgrade copy. + if [ -f "$hypr_dir/hyprland.lua" ]; then + echo "${NOTE:-[NOTE]} Existing Hyprland Lua config detected; migration will refresh Lua overlays after upgrade." 2>&1 | tee -a "$log" + export MIGRATE_HYPR_TO_LUA + return 0 + fi + + printf "\n%.0s" {1..1} + echo "${WARNING:-[WARN]} Hyprland will be LUA-only in the next release.${RESET:-}" + echo "${NOTE:-[NOTE]} This upgrade will migrate your Hyprlang (.conf) configuration to LUA." + echo "${NOTE:-[NOTE]} A backup is created first; hyprland.conf remains as fallback." + while true; do + if ! read -r -p "${CAT:-[ACTION]} Configuration will be migrated to LUA. Continue? (Y/n): " lua_migrate_choice </dev/tty; then + echo "${WARN:-[WARN]} Unable to read input; defaulting to migrate to LUA." 2>&1 | tee -a "$log" + break + fi + case "$lua_migrate_choice" in + [Yy] | [Yy][Ee][Ss] | "") + MIGRATE_HYPR_TO_LUA=1 + echo "${INFO:-[INFO]} LUA migration approved for this upgrade." 2>&1 | tee -a "$log" + break + ;; + [Nn] | [Nn][Oo]) + MIGRATE_HYPR_TO_LUA=0 + echo "${WARN:-[WARN]} Skipping LUA migration; remaining on Hyprlang (.conf) for now." 2>&1 | tee -a "$log" + echo "${NOTE:-[NOTE]} You can migrate later with: scripts/migrate-hypr-to-lua.sh" 2>&1 | tee -a "$log" + break + ;; + *) + echo "${WARN:-[WARN]} Please answer Y or n." + ;; + esac + done + + export MIGRATE_HYPR_TO_LUA +} + # Express upgrade confirmation; may set EXPRESS_MODE=1. prompt_express_upgrade() { local express_supported="$1" |
