aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/fix-systemsettings-lua.sh4
-rw-r--r--scripts/lib_apps.sh4
-rw-r--r--scripts/lib_backup.sh4
-rw-r--r--scripts/lib_copy.sh87
-rw-r--r--scripts/lib_detect.sh66
-rw-r--r--scripts/lib_prompts.sh4
-rwxr-xr-xscripts/migrate-hypr-to-lua.sh82
7 files changed, 201 insertions, 50 deletions
diff --git a/scripts/fix-systemsettings-lua.sh b/scripts/fix-systemsettings-lua.sh
index e1b550fc..42515d87 100755
--- a/scripts/fix-systemsettings-lua.sh
+++ b/scripts/fix-systemsettings-lua.sh
@@ -5,11 +5,11 @@
# License: GNU GPLv3
# SPDX-License-Identifier: GPL-3.0-or-later
# ==================================================
-# Regenerate ~/.config/hypr/configs/system_settings.lua from SystemSettings.conf.
+# Regenerate ${XDG_CONFIG_HOME:-$HOME/.config}/hypr/configs/system_settings.lua from SystemSettings.conf.
set -euo pipefail
-CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
+CONFIG_HOME="${XDG_CONFIG_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}}"
HYPR_DIR="${CONFIG_HOME}/hypr"
CONFIGS_DIR="${HYPR_DIR}/configs"
LEGACY_DIR="${CONFIGS_DIR}/LegacyConfigs"
diff --git a/scripts/lib_apps.sh b/scripts/lib_apps.sh
index 579b5fd2..55c457d5 100644
--- a/scripts/lib_apps.sh
+++ b/scripts/lib_apps.sh
@@ -74,7 +74,7 @@ install_terminal_configs() {
# Ghostty
local GHOSTTY_SRC="$base/config/ghostty/config"
- local GHOSTTY_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/ghostty"
+ local GHOSTTY_DIR="${XDG_CONFIG_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}}/ghostty"
local GHOSTTY_DEST="$GHOSTTY_DIR/config"
if [ -f "$GHOSTTY_SRC" ]; then
if [ -d "$GHOSTTY_DIR" ]; then
@@ -96,7 +96,7 @@ install_terminal_configs() {
# WezTerm
local WEZTERM_SRC="$base/config/wezterm/wezterm.lua"
- local WEZTERM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/wezterm"
+ local WEZTERM_DIR="${XDG_CONFIG_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}}/wezterm"
local WEZTERM_DEST="$WEZTERM_DIR/wezterm.lua"
if [ -f "$WEZTERM_SRC" ]; then
mkdir -p "$WEZTERM_DIR"
diff --git a/scripts/lib_backup.sh b/scripts/lib_backup.sh
index b6f54f6a..5abcf0eb 100644
--- a/scripts/lib_backup.sh
+++ b/scripts/lib_backup.sh
@@ -30,12 +30,12 @@ backup_dir() {
mv "$dir" "${dir}-backup-${backup_suffix}" 2>&1 | tee -a "$log"
}
-# Cleanup old backups under ~/.config, keeping the newest for each base dir.
+# Cleanup old backups under ${XDG_CONFIG_HOME:-$HOME/.config}, keeping the newest for each base dir.
# mode: "auto" (no prompts) or "prompt" (asks before delete); log optional.
cleanup_backups() {
local mode="${1:-prompt}"
local log="${2:-/dev/null}"
- local CONFIG_DIR="$HOME/.config"
+ local CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}"
local BACKUP_PREFIX="-backup"
for DIR in "$CONFIG_DIR"/*; do
diff --git a/scripts/lib_copy.sh b/scripts/lib_copy.sh
index 9a1c0444..f31ca1a8 100644
--- a/scripts/lib_copy.sh
+++ b/scripts/lib_copy.sh
@@ -12,10 +12,10 @@ copy_phase1() {
local base="${DOTFILES_DIR:-.}"
local dirs="fastfetch kitty rofi swaync"
for DIR2 in $dirs; do
- local DIRPATH="$HOME/.config/$DIR2"
+ local DIRPATH="${XDG_CONFIG_HOME:-$HOME/.config}/$DIR2"
if [ -d "$DIRPATH" ]; then
while true; do
- printf "\n${INFO:-[INFO]} Found ${YELLOW:-}$DIR2${RESET:-} config found in ~/.config/\n"
+ printf "\n${INFO:-[INFO]} Found ${YELLOW:-}$DIR2${RESET:-} config found in ${XDG_CONFIG_HOME:-$HOME/.config}/\n"
echo -n "${CAT:-[ACTION]} Do you want to replace ${YELLOW:-}$DIR2${RESET:-} config? (y/n): "
read DIR1_CHOICE
case "$DIR1_CHOICE" in
@@ -23,17 +23,17 @@ copy_phase1() {
BACKUP_DIR=$(get_backup_dirname)
mv "$DIRPATH" "$DIRPATH-backup-$BACKUP_DIR" 2>&1 | tee -a "$log"
echo -e "${NOTE:-[NOTE]} - Backed up $DIR2 to $DIRPATH-backup-$BACKUP_DIR." 2>&1 | tee -a "$log"
- cp -r "$base/config/$DIR2" "$HOME/.config/$DIR2" 2>&1 | tee -a "$log"
+ cp -r "$base/config/$DIR2" "${XDG_CONFIG_HOME:-$HOME/.config}/$DIR2" 2>&1 | tee -a "$log"
echo -e "${OK:-[OK]} - Replaced $DIR2 with new configuration." 2>&1 | tee -a "$log"
if [ "$DIR2" = "rofi" ]; then
if [ -d "$DIRPATH-backup-$BACKUP_DIR/themes" ]; then
for file in "$DIRPATH-backup-$BACKUP_DIR/themes"/*; do
[ -e "$file" ] || continue
- cp -n "$file" "$HOME/.config/rofi/themes/" >>"$log" 2>&1 || true
+ cp -n "$file" "${XDG_CONFIG_HOME:-$HOME/.config}/rofi/themes/" >>"$log" 2>&1 || true
done || true
fi
if [ -f "$DIRPATH-backup-$BACKUP_DIR/0-shared-fonts.rasi" ]; then
- cp "$DIRPATH-backup-$BACKUP_DIR/0-shared-fonts.rasi" "$HOME/.config/rofi/0-shared-fonts.rasi" >>"$log" 2>&1
+ cp "$DIRPATH-backup-$BACKUP_DIR/0-shared-fonts.rasi" "${XDG_CONFIG_HOME:-$HOME/.config}/rofi/0-shared-fonts.rasi" >>"$log" 2>&1
fi
fi
break
@@ -46,7 +46,7 @@ copy_phase1() {
esac
done
else
- cp -r "$base/config/$DIR2" "$HOME/.config/$DIR2" 2>&1 | tee -a "$log"
+ cp -r "$base/config/$DIR2" "${XDG_CONFIG_HOME:-$HOME/.config}/$DIR2" 2>&1 | tee -a "$log"
echo -e "${OK:-[OK]} - Copy completed for ${YELLOW:-}$DIR2${RESET:-}" 2>&1 | tee -a "$log"
fi
done
@@ -56,7 +56,7 @@ copy_waybar() {
local log="$1"
local base="${DOTFILES_DIR:-.}"
local DIRW="waybar"
- local DIRPATHw="$HOME/.config/$DIRW"
+ local DIRPATHw="${XDG_CONFIG_HOME:-$HOME/.config}/$DIRW"
if [ -d "$DIRPATHw" ]; then
while true; do
echo -n "${CAT:-[ACTION]} Do you want to replace ${YELLOW:-}$DIRW${RESET:-} config? (y/n): "
@@ -80,23 +80,23 @@ copy_waybar() {
for dir in "$DIRPATHw-backup-$BACKUP_DIR/configs"/*; do
[ -e "$dir" ] || continue
if [ -d "$dir" ]; then
- target_dir="$HOME/.config/waybar/configs/$(basename "$dir")"
- [ -d "$target_dir" ] || cp -r "$dir" "$HOME/.config/waybar/configs/"
+ target_dir="${XDG_CONFIG_HOME:-$HOME/.config}/waybar/configs/$(basename "$dir")"
+ [ -d "$target_dir" ] || cp -r "$dir" "${XDG_CONFIG_HOME:-$HOME/.config}/waybar/configs/"
fi
done
for file in "$DIRPATHw-backup-$BACKUP_DIR/configs"/*; do
[ -e "$file" ] || continue
- target_file="$HOME/.config/waybar/configs/$(basename "$file")"
- [ -e "$target_file" ] || cp "$file" "$HOME/.config/waybar/configs/"
+ target_file="${XDG_CONFIG_HOME:-$HOME/.config}/waybar/configs/$(basename "$file")"
+ [ -e "$target_file" ] || cp "$file" "${XDG_CONFIG_HOME:-$HOME/.config}/waybar/configs/"
done || true
for file in "$DIRPATHw-backup-$BACKUP_DIR/style"/*; do
[ -e "$file" ] || continue
if [ -d "$file" ]; then
- target_dir="$HOME/.config/waybar/style/$(basename "$file")"
- [ -d "$target_dir" ] || cp -r "$file" "$HOME/.config/waybar/style/"
+ target_dir="${XDG_CONFIG_HOME:-$HOME/.config}/waybar/style/$(basename "$file")"
+ [ -d "$target_dir" ] || cp -r "$file" "${XDG_CONFIG_HOME:-$HOME/.config}/waybar/style/"
else
- target_file="$HOME/.config/waybar/style/$(basename "$file")"
- [ -e "$target_file" ] || cp "$file" "$HOME/.config/waybar/style/"
+ target_file="${XDG_CONFIG_HOME:-$HOME/.config}/waybar/style/$(basename "$file")"
+ [ -e "$target_file" ] || cp "$file" "${XDG_CONFIG_HOME:-$HOME/.config}/waybar/style/"
fi
done || true
BACKUP_FILEw="$DIRPATHw-backup-$BACKUP_DIR/UserModules"
@@ -119,16 +119,16 @@ copy_waybar() {
copy_phase2() {
local log="$1"
local base="${DOTFILES_DIR:-.}"
- local DIR="btop cava hypr Kvantum qt5ct qt6ct swappy wallust wlogout yazi"
+ local DIR="btop cava hypr Kvantum qt5ct qt6ct starship swappy wallust wlogout yazi"
for DIR_NAME in $DIR; do
- local DIRPATH="$HOME/.config/$DIR_NAME"
+ local DIRPATH="${XDG_CONFIG_HOME:-$HOME/.config}/$DIR_NAME"
if [ -d "$DIRPATH" ]; then
echo -e "\n${NOTE:-[NOTE]} - Config for ${YELLOW:-}$DIR_NAME${RESET:-} found, attempting to back up."
BACKUP_DIR=$(get_backup_dirname)
mv "$DIRPATH" "$DIRPATH-backup-$BACKUP_DIR" 2>&1 | tee -a "$log"
fi
if [ -d "$base/config/$DIR_NAME" ]; then
- cp -r "$base/config/$DIR_NAME/" "$HOME/.config/$DIR_NAME" 2>&1 | tee -a "$log"
+ cp -r "$base/config/$DIR_NAME/" "${XDG_CONFIG_HOME:-$HOME/.config}/$DIR_NAME" 2>&1 | tee -a "$log"
echo "${OK:-[OK]} - Copy of config for ${YELLOW:-}$DIR_NAME${RESET:-} completed!" 2>&1 | tee -a "$log"
else
echo "${ERROR:-[ERROR]} - Directory config/$DIR_NAME does not exist to copy." 2>&1 | tee -a "$log"
@@ -137,13 +137,48 @@ copy_phase2() {
install_terminal_configs "$log"
}
+ensure_lua_keybinds() {
+ local log="$1"
+ local base="${DOTFILES_DIR:-.}"
+ local src_root="$base/config/hypr"
+ local dst_root="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
+ local copied=0
+ local rel_dir src_dir src_file rel_path dst_file
+
+ for rel_dir in configs UserConfigs lua; do
+ src_dir="$src_root/$rel_dir"
+ [ -d "$src_dir" ] || continue
+
+ while IFS= read -r -d '' src_file; do
+ rel_path="${src_file#$src_root/}"
+ dst_file="$dst_root/$rel_path"
+
+ if [ ! -f "$dst_file" ]; then
+ mkdir -p "$(dirname "$dst_file")"
+ if cp -f "$src_file" "$dst_file" 2>&1 | tee -a "$log"; then
+ copied=1
+ echo "${NOTE:-[NOTE]} - Added missing Lua file: ${YELLOW:-}$rel_path${RESET:-}" 2>&1 | tee -a "$log"
+ else
+ echo "${ERROR:-[ERROR]} - Failed to add missing Lua file: ${YELLOW:-}$rel_path${RESET:-}" 2>&1 | tee -a "$log"
+ fi
+ fi
+ done < <(find "$src_dir" -maxdepth 1 -type f -name '*.lua' -print0)
+ done
+
+ if [ "$copied" -eq 1 ]; then
+ echo "${OK:-[OK]} - Lua fallback copy completed." 2>&1 | tee -a "$log"
+ else
+ echo "${INFO:-[INFO]} - Lua fallback check: no missing Lua files detected." 2>&1 | tee -a "$log"
+ fi
+}
+
# Restore Animations and Monitor Profiles plus key hypr files from backup
restore_hypr_assets() {
local log="$1"
local express_mode="$2"
- local HYPR_DIR="$HOME/.config/hypr"
- local CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
+ local HYPR_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
+ local CONFIG_HOME="${XDG_CONFIG_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}}"
local BACKUP_DIR
BACKUP_DIR=$(get_backup_dirname)
local BACKUP_HYPR_PATH="$HYPR_DIR-backup-$BACKUP_DIR"
@@ -272,7 +307,7 @@ cleanup_duplicate_userconfigs() {
echo "${INFO:-[INFO]} Running UserConfigs duplicate cleanup for detected version v$current_version (<= 2.3.18)." 2>&1 | tee -a "$log"
- local HYPR_DIR="$HOME/.config/hypr"
+ local HYPR_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
local BASE_DIR="$HYPR_DIR/configs"
local USER_DIR="$HYPR_DIR/UserConfigs"
@@ -389,7 +424,7 @@ restore_user_configs() {
local express_mode="$2"
local old_version="$3"
- local DIRPATH="$HOME/.config/hypr"
+ local DIRPATH="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
local BACKUP_DIR
BACKUP_DIR=$(get_backup_dirname)
local BACKUP_DIR_PATH="$DIRPATH-backup-$BACKUP_DIR/UserConfigs"
@@ -535,7 +570,7 @@ restore_user_scripts() {
local log="$1"
local express_mode="$2"
- local DIRSHPATH="$HOME/.config/hypr"
+ local DIRSHPATH="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
local BACKUP_DIR
BACKUP_DIR=$(get_backup_dirname)
local BACKUP_DIR_PATH_S="$DIRSHPATH-backup-$BACKUP_DIR/UserScripts"
@@ -573,7 +608,7 @@ restore_terminal_configs() {
local log="$1"
local express_mode="$2"
- local GHOSTTY_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/ghostty"
+ local GHOSTTY_DIR="${XDG_CONFIG_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}}/ghostty"
local BACKUP_DIR
BACKUP_DIR=$(get_backup_dirname)
local GHOSTTY_BACKUP="$GHOSTTY_DIR-backup-$BACKUP_DIR"
@@ -599,7 +634,7 @@ restore_hypr_files() {
local log="$1"
local express_mode="$2"
- local DIRPATH="$HOME/.config/hypr"
+ local DIRPATH="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
local BACKUP_DIR
BACKUP_DIR=$(get_backup_dirname)
local BACKUP_DIR_PATH_F="$DIRPATH-backup-$BACKUP_DIR"
@@ -611,7 +646,7 @@ restore_hypr_files() {
fi
if [ -d "$BACKUP_DIR_PATH_F" ] && [ "$express_mode" -eq 0 ]; then
- echo -e "${NOTE:-[NOTE]} Restoring some files in ${MAGENTA:-}$HOME/.config/hypr directory${RESET:-}..." 2>&1 | tee -a "$log"
+ echo -e "${NOTE:-[NOTE]} Restoring some files in ${MAGENTA:-}${XDG_CONFIG_HOME:-$HOME/.config}/hypr directory${RESET:-}..." 2>&1 | tee -a "$log"
for FILE_RESTORE in "${FILES_2_RESTORE[@]}"; do
local BACKUP_FILE="$BACKUP_DIR_PATH_F/$FILE_RESTORE"
diff --git a/scripts/lib_detect.sh b/scripts/lib_detect.sh
index 2b11baac..5bb42c3f 100644
--- a/scripts/lib_detect.sh
+++ b/scripts/lib_detect.sh
@@ -10,13 +10,35 @@
# Nvidia tweaks: uncomments envs and adjusts hardware cursor setting.
detect_nvidia_adjust() {
local log="$1"
- if lspci -k | grep -A 2 -E "(VGA|3D)" | grep -iq nvidia; then
+ local pci_info
+ local has_nvidia=0
+ local has_intel=0
+ local has_amd=0
+ pci_info="$(lspci -k | grep -A 2 -E "(VGA|3D)" || true)"
+ if echo "$pci_info" | grep -iq nvidia; then
+ has_nvidia=1
+ fi
+ if echo "$pci_info" | grep -iq intel; then
+ has_intel=1
+ fi
+ if echo "$pci_info" | grep -Eiq 'amd|advanced micro devices|ati'; then
+ has_amd=1
+ fi
+ if [ "$has_nvidia" -eq 1 ]; then
echo "${INFO:-[INFO]} Nvidia GPU detected. Setting up proper env's and configs" 2>&1 | tee -a "$log" || true
sed -i '/env = LIBVA_DRIVER_NAME,nvidia/s/^#//' config/hypr/configs/ENVariables.conf
sed -i '/env = __GLX_VENDOR_LIBRARY_NAME,nvidia/s/^#//' config/hypr/configs/ENVariables.conf
sed -i '/env = NVD_BACKEND,direct/s/^#//' config/hypr/configs/ENVariables.conf
sed -i '/env = GSK_RENDERER,ngl/s/^#//' config/hypr/configs/ENVariables.conf
- sed -i 's/^\([[:space:]]*no_hardware_cursors[[:space:]]*=[[:space:]]*\)2/\1 1/' config/hypr/configs/SystemSettings.conf
+ if [ "$has_intel" -eq 1 ] || [ "$has_amd" -eq 1 ]; then
+ echo "${INFO:-[INFO]} Hybrid GPU detected (Intel/NVIDIA or AMD/NVIDIA). Applying cursor handoff fixes." 2>&1 | tee -a "$log" || true
+ sed -i -E 's/^([[:space:]]*no_hardware_cursors[[:space:]]*=[[:space:]]*)[0-9]+/\1 0/' config/hypr/configs/SystemSettings.conf
+ sed -i -E 's/^([[:space:]]*no_hardware_cursors[[:space:]]*=[[:space:]]*)[0-9]+/\1 0/' config/hypr/lua/settings.lua
+ sed -i '/hyprctl setcursor/s/^#//' config/hypr/configs/Startup_Apps.conf
+ else
+ sed -i -E 's/^([[:space:]]*no_hardware_cursors[[:space:]]*=[[:space:]]*)[0-9]+/\1 1/' config/hypr/configs/SystemSettings.conf
+ sed -i -E 's/^([[:space:]]*no_hardware_cursors[[:space:]]*=[[:space:]]*)[0-9]+/\1 1/' config/hypr/lua/settings.lua
+ fi
fi
}
@@ -44,6 +66,46 @@ detect_nixos_adjust() {
grep -qx '\$scriptsDir/Polkit.sh' "$DISABLE_SA" || echo '$scriptsDir/Polkit.sh' >>"$DISABLE_SA"
fi
}
+# Qt Quick Controls style safety: enable Hyprland style only when module exists.
+adjust_qt_quick_controls_style() {
+ local log="$1"
+ local env_conf="config/hypr/configs/ENVariables.conf"
+ local env_lua="config/hypr/lua/env.lua"
+ local style="Basic"
+ local qt_style_override="Fusion"
+ local has_kvantum_qml=0
+
+ if find /usr/lib /usr/lib64 /usr/share -type d -path '*/qml/*/org/hyprland/style' -print -quit 2>/dev/null | grep -q .; then
+ style="org.hyprland.style"
+ elif command -v dpkg >/dev/null 2>&1 && dpkg -s qml6-module-org-hyprland-style >/dev/null 2>&1; then
+ style="org.hyprland.style"
+ fi
+
+ if find /usr/lib /usr/lib64 /usr/share -type d -path '*/qml/*/kvantum' -print -quit 2>/dev/null | grep -q .; then
+ has_kvantum_qml=1
+ qt_style_override="kvantum"
+ fi
+
+ if [ -f "$env_conf" ]; then
+ sed -i -E "s|^env = QT_QUICK_CONTROLS_STYLE,.*$|env = QT_QUICK_CONTROLS_STYLE,${style}|" "$env_conf"
+ sed -i -E "s|^env = QT_STYLE_OVERRIDE,.*$|env = QT_STYLE_OVERRIDE,${qt_style_override}|" "$env_conf"
+ fi
+ if [ -f "$env_lua" ]; then
+ sed -i -E "s|^hl\\.env\\(\"QT_QUICK_CONTROLS_STYLE\", \".*\"\\)$|hl.env(\"QT_QUICK_CONTROLS_STYLE\", \"${style}\")|" "$env_lua"
+ sed -i -E "s|^hl\\.env\\(\"QT_STYLE_OVERRIDE\", \".*\"\\)$|hl.env(\"QT_STYLE_OVERRIDE\", \"${qt_style_override}\")|" "$env_lua"
+ fi
+
+ if [ "$style" = "org.hyprland.style" ]; then
+ echo "${INFO:-[INFO]} hyprland Qt style module detected. Using QT_QUICK_CONTROLS_STYLE=$style" 2>&1 | tee -a "$log" || true
+ else
+ echo "${WARN:-[WARN]} hyprland Qt style module not found. Using QT_QUICK_CONTROLS_STYLE=Basic to avoid Qt app crashes." 2>&1 | tee -a "$log" || true
+ fi
+ if [ "$has_kvantum_qml" -eq 1 ]; then
+ echo "${INFO:-[INFO]} Kvantum QML module detected. Using QT_STYLE_OVERRIDE=kvantum" 2>&1 | tee -a "$log" || true
+ else
+ echo "${WARN:-[WARN]} Kvantum QML module not found. Using QT_STYLE_OVERRIDE=Fusion as fallback." 2>&1 | tee -a "$log" || true
+ fi
+}
# Decide waybar config/style based on chassis type. Echoes chosen config path.
detect_waybar_config() {
diff --git a/scripts/lib_prompts.sh b/scripts/lib_prompts.sh
index 8f2db3bc..bd8d9c75 100644
--- a/scripts/lib_prompts.sh
+++ b/scripts/lib_prompts.sh
@@ -45,7 +45,7 @@ You need to set it Manually
Setting a wrong Keyboard Layout will cause Hyprland to crash
If you are not sure, just type ${YELLOW}us${RESET}
-${SKYBLUE}You can change later in ~/.config/hypr/UserConfigs/UserSettings.conf${RESET}
+${SKYBLUE}You can change later in ${XDG_CONFIG_HOME:-$HOME/.config}/hypr/UserConfigs/UserSettings.conf${RESET}
${MAGENTA} NOTE:${RESET}
• You can also set more than 2 keyboard layouts
@@ -93,7 +93,7 @@ You need to set it Manually
Setting a wrong Keyboard Layout will cause Hyprland to crash
If you are not sure, just type ${YELLOW}us${RESET}
-${SKYBLUE}You can change later in ~/.config/hypr/UserConfigs/UserSettings.conf${RESET}
+${SKYBLUE}You can change later in ${XDG_CONFIG_HOME:-$HOME/.config}/hypr/UserConfigs/UserSettings.conf${RESET}
${MAGENTA} NOTE:${RESET}
• You can also set more than 2 keyboard layouts
diff --git a/scripts/migrate-hypr-to-lua.sh b/scripts/migrate-hypr-to-lua.sh
index ccbd6ed9..a3e4c78c 100755
--- a/scripts/migrate-hypr-to-lua.sh
+++ b/scripts/migrate-hypr-to-lua.sh
@@ -12,7 +12,7 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
SRC_HYPR_DIR="$REPO_DIR/config/hypr"
-DEST_HYPR_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr"
+DEST_HYPR_DIR="${XDG_CONFIG_HOME:-${XDG_CONFIG_HOME:-$HOME/.config}}/hypr"
BACKUP_DIR="${DEST_HYPR_DIR}-backup-lua-$(date +%Y%m%d-%H%M%S)"
MIGRATION_TS="$(date +%Y%m%d-%H%M%S)"
DRY_RUN=0
@@ -49,6 +49,7 @@ DEST_WORKSPACES_CONF="$DEST_HYPR_DIR/workspaces.conf"
DEST_LUA_WORKSPACES="$DEST_HYPR_DIR/lua/workspaces.lua"
SOURCE_LUA_ENTRY_ENABLED="$SRC_HYPR_DIR/hyprland.lua"
SOURCE_LUA_ENTRY_DISABLED="$SRC_HYPR_DIR/hyprland.lua.disable"
+SRC_USER_LUA_TEMPLATES_DIR="$SRC_HYPR_DIR/UserConfigs"
DEST_LUA_ENTRY="$DEST_HYPR_DIR/hyprland.lua"
DEST_LUA_ENTRY_DISABLED="$DEST_HYPR_DIR/hyprland.lua.disable"
SOURCE_LUA_ENTRY=""
@@ -163,6 +164,51 @@ restore_latest_conf_backup() {
fi
}
+has_active_hyprlang_content() {
+ local source_conf="$1"
+ [ -f "$source_conf" ] || return 1
+ grep -Eq '^[[:space:]]*[^#[:space:]]' "$source_conf"
+}
+
+lua_file_is_generated() {
+ local lua_path="$1"
+ [ -f "$lua_path" ] || return 1
+ grep -Eq 'auto-generated|Converted from|No active entries were found|Source reference from' "$lua_path"
+}
+
+ensure_template_for_empty_user_conf() {
+ local source_conf="$1"
+ local target_lua="$2"
+ local template_lua="$3"
+
+ [ -f "$template_lua" ] || return 0
+
+ if has_active_hyprlang_content "$source_conf"; then
+ return 0
+ fi
+
+ if [ -f "$target_lua" ] && ! lua_file_is_generated "$target_lua"; then
+ echo "[INFO] Preserving customized Lua file for empty/default source: $target_lua"
+ return 0
+ fi
+
+ cp -f "$template_lua" "$target_lua"
+ echo "[OK] Ensured template for empty/default source: $source_conf -> $target_lua"
+}
+
+ensure_templates_for_empty_user_configs() {
+ ensure_template_for_empty_user_conf "$USER_ENV_VARS" "$USER_CONFIGS_DIR/user_env.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_env.lua"
+ ensure_template_for_empty_user_conf "$USER_STARTUP_APPS" "$USER_CONFIGS_DIR/user_startup.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_startup.lua"
+ ensure_template_for_empty_user_conf "$USER_WINDOW_RULES" "$USER_CONFIGS_DIR/user_window_rules.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_window_rules.lua"
+ ensure_template_for_empty_user_conf "$USER_LAYER_RULES" "$USER_CONFIGS_DIR/user_layer_rules.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_layer_rules.lua"
+ ensure_template_for_empty_user_conf "$USER_KEYBINDS" "$USER_CONFIGS_DIR/user_keybinds.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_keybinds.lua"
+ ensure_template_for_empty_user_conf "$USER_SETTINGS" "$USER_CONFIGS_DIR/user_settings.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_settings.lua"
+ ensure_template_for_empty_user_conf "$USER_DECORATIONS" "$USER_CONFIGS_DIR/user_decorations.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_decorations.lua"
+ ensure_template_for_empty_user_conf "$USER_ANIMATIONS" "$USER_CONFIGS_DIR/user_animations.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_animations.lua"
+ ensure_template_for_empty_user_conf "$USER_LAPTOPS" "$USER_CONFIGS_DIR/user_laptops.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_laptops.lua"
+ ensure_template_for_empty_user_conf "$USER_CONFIGS_DIR/01-UserDefaults.conf" "$USER_CONFIGS_DIR/user_defaults.lua" "$SRC_USER_LUA_TEMPLATES_DIR/user_defaults.lua"
+}
+
if [ "$YES" -eq 0 ]; then
if [ "$REVERT" -eq 1 ]; then
printf "[ACTION] Continue and revert Lua migration using latest legacy archives? [y/N] "
@@ -199,10 +245,15 @@ if [ "$DRY_RUN" -eq 1 ]; then
fi
if [ -f "$DEST_LUA_ENTRY_DISABLED" ]; then
echo "[DRY-RUN] Would enable Lua entrypoint: $DEST_LUA_ENTRY_DISABLED -> $DEST_LUA_ENTRY"
+ fi
+ if [ -n "$SOURCE_LUA_ENTRY" ]; then
+ if [ -f "$DEST_LUA_ENTRY" ]; then
+ echo "[DRY-RUN] Would refresh Lua entrypoint from template: $SOURCE_LUA_ENTRY -> $DEST_LUA_ENTRY"
+ else
+ echo "[DRY-RUN] Would install Lua entrypoint: $SOURCE_LUA_ENTRY -> $DEST_LUA_ENTRY"
+ fi
elif [ -f "$DEST_LUA_ENTRY" ]; then
- echo "[DRY-RUN] Lua entrypoint already enabled: $DEST_LUA_ENTRY"
- elif [ -n "$SOURCE_LUA_ENTRY" ]; then
- echo "[DRY-RUN] Would install Lua entrypoint: $SOURCE_LUA_ENTRY -> $DEST_LUA_ENTRY"
+ echo "[DRY-RUN] Lua entrypoint already enabled: $DEST_LUA_ENTRY (no source template available to refresh)"
fi
echo "[DRY-RUN] Would replace Lua module directory: $DEST_HYPR_DIR/lua"
echo "[DRY-RUN] Would generate split configs/UserConfigs Lua overlays:"
@@ -223,6 +274,7 @@ if [ "$DRY_RUN" -eq 1 ]; then
echo "[DRY-RUN] - $USER_CONFIGS_DIR/user_animations.lua"
echo "[DRY-RUN] - $USER_CONFIGS_DIR/user_laptops.lua"
echo "[DRY-RUN] - $USER_CONFIGS_DIR/user_defaults.lua"
+ echo "[DRY-RUN] Would ensure repo Lua templates for empty/default UserConfigs/*.conf files."
echo "[DRY-RUN] - $DEST_LUA_MONITORS (generated from $DEST_MONITORS_CONF)"
echo "[DRY-RUN] - $DEST_LUA_WORKSPACES (generated from $DEST_WORKSPACES_CONF)"
if [ -d "$USER_CONFIGS_DIR" ]; then
@@ -264,11 +316,12 @@ if [ -f "$DEST_LUA_ENTRY_DISABLED" ]; then
mv "$DEST_LUA_ENTRY_DISABLED" "$DEST_LUA_ENTRY"
echo "[OK] Enabled Lua entrypoint: $DEST_LUA_ENTRY"
fi
-elif [ -f "$DEST_LUA_ENTRY" ]; then
- echo "[INFO] Lua entrypoint already enabled: $DEST_LUA_ENTRY"
-elif [ -n "$SOURCE_LUA_ENTRY" ]; then
+fi
+if [ -n "$SOURCE_LUA_ENTRY" ]; then
cp -f "$SOURCE_LUA_ENTRY" "$DEST_LUA_ENTRY"
- echo "[OK] Installed Lua entrypoint: $SOURCE_LUA_ENTRY -> $DEST_LUA_ENTRY"
+ echo "[OK] Installed/updated Lua entrypoint: $SOURCE_LUA_ENTRY -> $DEST_LUA_ENTRY"
+elif [ -f "$DEST_LUA_ENTRY" ]; then
+ echo "[INFO] Lua entrypoint already enabled: $DEST_LUA_ENTRY (source template unavailable; keeping existing entrypoint)"
else
echo "[ERROR] Unable to locate a Lua entrypoint to enable." >&2
exit 1
@@ -1483,16 +1536,16 @@ system_keybind_lines = [
" end",
" if name == \"cyclenext\" then",
" if args == \"prev\" or args == \"b\" then",
- " return exec_cmd(\"$HOME/.config/hypr/scripts/LuaCycleWindow.sh previous\")",
+ " return exec_cmd(\"${XDG_CONFIG_HOME:-$HOME/.config}/hypr/scripts/LuaCycleWindow.sh previous\")",
" end",
- " return exec_cmd(\"$HOME/.config/hypr/scripts/LuaCycleWindow.sh next\")",
+ " return exec_cmd(\"${XDG_CONFIG_HOME:-$HOME/.config}/hypr/scripts/LuaCycleWindow.sh next\")",
" end",
" if name == \"swapwindow\" then",
" local swap_direction = trim(args)",
" if swap_direction == \"\" then",
" return nil",
" end",
- " return exec_cmd(\"$HOME/.config/hypr/scripts/LuaSwapWindow.sh \" .. swap_direction)",
+ " return exec_cmd(\"${XDG_CONFIG_HOME:-$HOME/.config}/hypr/scripts/LuaSwapWindow.sh \" .. swap_direction)",
" end",
" if name == \"workspace\" and dsp and dsp.focus then",
" return function() hl.dispatch(dsp.focus({ workspace = workspace_value(args) })) end",
@@ -1688,7 +1741,7 @@ startup_lines = [
"-- User startup overrides (auto-generated).",
"-- Add commands with exec_once(\"your command\")",
"-- Example:",
- "-- exec_once(\"$HOME/.config/hypr/UserScripts/MyStartup.sh\")",
+ "-- exec_once(\"${XDG_CONFIG_HOME:-$HOME/.config}/hypr/UserScripts/MyStartup.sh\")",
"",
"local user_startup_helper = nil",
"do",
@@ -1870,7 +1923,7 @@ keybind_lines = [
"-- Add keybinds with bind(\"MODS\", \"KEY\", fn, opts).",
"-- Example:",
"-- bind(\"SUPER\", \"Z\", exec_cmd(\"ghostty\"), { description = \"Launch ghostty\" })",
- "-- Helper functions live in ~/.config/hypr/lua/user_keybinds_helper.lua so they can be updated separately.",
+ "-- Helper functions live in ${XDG_CONFIG_HOME:-$HOME/.config}/hypr/lua/user_keybinds_helper.lua so they can be updated separately.",
"local user_keybinds_helper = nil",
"do",
" local source = (debug.getinfo(1, \"S\") or {}).source or \"\"",
@@ -2085,6 +2138,7 @@ for name, source in [
lines.append(f"-- No active entries were found in {source.name}.")
write_file(files_out[name], lines)
PY
+ensure_templates_for_empty_user_configs
cat > "$USER_OVERRIDES_SHIM" <<'LUA'
-- ==================================================
@@ -2094,7 +2148,7 @@ cat > "$USER_OVERRIDES_SHIM" <<'LUA'
-- SPDX-License-Identifier: GPL-3.0-or-later
-- ==================================================
-- Auto-generated by scripts/migrate-hypr-to-lua.sh.
--- Loads split system/user Lua files from ~/.config/hypr/configs and ~/.config/hypr/UserConfigs.
+-- Loads split system/user Lua files from ${XDG_CONFIG_HOME:-$HOME/.config}/hypr/configs and ${XDG_CONFIG_HOME:-$HOME/.config}/hypr/UserConfigs.
local configHome = os.getenv("XDG_CONFIG_HOME") or ((os.getenv("HOME") or "") .. "/.config")
local hyprDir = configHome .. "/hypr"
local systemDir = hyprDir .. "/configs"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage