diff options
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rwxr-xr-x | config/hypr/scripts/DarkLight.sh | 39 | ||||
| -rwxr-xr-x | config/hypr/scripts/Ghostty_themes.sh | 24 | ||||
| -rwxr-xr-x | config/hypr/scripts/Kitty_themes.sh | 27 | ||||
| -rwxr-xr-x | scripts/migrate-hypr-to-lua.sh | 27 |
5 files changed, 107 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f35ec319..ff287207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ## Added: +- `kitty.conf` and `ghostty/config` are now saved to `UserConfigs` directory + - If file is gone or can't be read it will fall back to defaults - `qs-hyprview` an alternative to quickshell `overview` - `CTRL-TAB` to activate - Has search filter diff --git a/config/hypr/scripts/DarkLight.sh b/config/hypr/scripts/DarkLight.sh index 16f1a4ef..e8e69910 100755 --- a/config/hypr/scripts/DarkLight.sh +++ b/config/hypr/scripts/DarkLight.sh @@ -25,7 +25,9 @@ theme_state_dir="${XDG_STATE_HOME:-$HOME/.local/state}/hypr" theme_state_file="$theme_state_dir/theme_mode" legacy_theme_state_file="$HOME/.cache/.theme_mode" -kitty_conf="${XDG_CONFIG_HOME:-$HOME/.config}/kitty/kitty.conf" +user_kitty_conf="${XDG_CONFIG_HOME:-$HOME/.config}/hypr/UserConfigs/kitty.conf" +fallback_kitty_conf="${XDG_CONFIG_HOME:-$HOME/.config}/kitty/kitty.conf" +kitty_conf="$user_kitty_conf" wallust_config="${XDG_CONFIG_HOME:-$HOME/.config}/wallust/wallust.toml" pallete_dark="dark16" @@ -39,6 +41,24 @@ notify_enabled=1 preserve_wallpaper=0 forced_mode="" +ensure_managed_kitty_conf() { + if [[ -f "$user_kitty_conf" && -r "$user_kitty_conf" ]]; then + kitty_conf="$user_kitty_conf" + return 0 + fi + + if [[ -r "$fallback_kitty_conf" ]]; then + mkdir -p "$(dirname "$user_kitty_conf")" 2>/dev/null || true + cp -f "$fallback_kitty_conf" "$user_kitty_conf" 2>/dev/null || true + if [[ -f "$user_kitty_conf" && -r "$user_kitty_conf" ]]; then + kitty_conf="$user_kitty_conf" + return 0 + fi + fi + + kitty_conf="$fallback_kitty_conf" +} + normalize_mode() { case "$1" in Dark|Light) printf '%s' "$1" ;; @@ -185,14 +205,19 @@ if command -v ags >/dev/null 2>&1; then fi # kitty background color change +ensure_managed_kitty_conf if [ "$next_mode" = "Dark" ]; then - sed -i '/^foreground /s/^foreground .*/foreground #dddddd/' "${kitty_conf}" - sed -i '/^background /s/^background .*/background #000000/' "${kitty_conf}" - sed -i '/^cursor /s/^cursor .*/cursor #dddddd/' "${kitty_conf}" + if [[ -w "$kitty_conf" ]]; then + sed -i '/^foreground /s/^foreground .*/foreground #dddddd/' "${kitty_conf}" + sed -i '/^background /s/^background .*/background #000000/' "${kitty_conf}" + sed -i '/^cursor /s/^cursor .*/cursor #dddddd/' "${kitty_conf}" + fi else - sed -i '/^foreground /s/^foreground .*/foreground #000000/' "${kitty_conf}" - sed -i '/^background /s/^background .*/background #dddddd/' "${kitty_conf}" - sed -i '/^cursor /s/^cursor .*/cursor #000000/' "${kitty_conf}" + if [[ -w "$kitty_conf" ]]; then + sed -i '/^foreground /s/^foreground .*/foreground #000000/' "${kitty_conf}" + sed -i '/^background /s/^background .*/background #dddddd/' "${kitty_conf}" + sed -i '/^cursor /s/^cursor .*/cursor #000000/' "${kitty_conf}" + fi fi for pid_kitty in $(pidof kitty); do diff --git a/config/hypr/scripts/Ghostty_themes.sh b/config/hypr/scripts/Ghostty_themes.sh index 1b0e1f9e..cc9158a6 100755 --- a/config/hypr/scripts/Ghostty_themes.sh +++ b/config/hypr/scripts/Ghostty_themes.sh @@ -7,7 +7,9 @@ # ================================================== # Ghostty theme selector -config_file="${XDG_CONFIG_HOME:-$HOME/.config}/ghostty/config" +user_ghostty_config="${XDG_CONFIG_HOME:-$HOME/.config}/hypr/UserConfigs/ghostty.conf" +fallback_ghostty_config="${XDG_CONFIG_HOME:-$HOME/.config}/ghostty/config" +config_file="$user_ghostty_config" iDIR="${XDG_CONFIG_HOME:-$HOME/.config}/swaync/images" rofi_theme_primary="${XDG_CONFIG_HOME:-$HOME/.config}/rofi/config-ghostty-theme.rasi" rofi_theme_fallback="${XDG_CONFIG_HOME:-$HOME/.config}/rofi/config-edit.rasi" @@ -33,8 +35,26 @@ refresh_wallpaper_theme() { fi pkill -SIGUSR2 ghostty >/dev/null 2>&1 || true } +ensure_managed_ghostty_config() { + if [[ -f "$user_ghostty_config" && -r "$user_ghostty_config" ]]; then + config_file="$user_ghostty_config" + return 0 + fi + + if [[ -r "$fallback_ghostty_config" ]]; then + mkdir -p "$(dirname "$user_ghostty_config")" 2>/dev/null || true + cp -f "$fallback_ghostty_config" "$user_ghostty_config" 2>/dev/null || true + if [[ -f "$user_ghostty_config" && -r "$user_ghostty_config" ]]; then + config_file="$user_ghostty_config" + return 0 + fi + fi + + config_file="$fallback_ghostty_config" +} -if [[ ! -f "$config_file" ]]; then +ensure_managed_ghostty_config +if [[ ! -f "$config_file" || ! -r "$config_file" ]]; then notify_user "$iDIR/error.png" "Ghostty Theme" "Config not found: $config_file" exit 1 fi diff --git a/config/hypr/scripts/Kitty_themes.sh b/config/hypr/scripts/Kitty_themes.sh index 5d6445e9..c1f1512f 100755 --- a/config/hypr/scripts/Kitty_themes.sh +++ b/config/hypr/scripts/Kitty_themes.sh @@ -9,12 +9,32 @@ # Define directories and variables kitty_themes_DiR="${XDG_CONFIG_HOME:-$HOME/.config}/kitty/kitty-themes" # Kitty Themes Directory -kitty_config="${XDG_CONFIG_HOME:-$HOME/.config}/kitty/kitty.conf" +user_kitty_config="${XDG_CONFIG_HOME:-$HOME/.config}/hypr/UserConfigs/kitty.conf" +fallback_kitty_config="${XDG_CONFIG_HOME:-$HOME/.config}/kitty/kitty.conf" +kitty_config="$user_kitty_config" iDIR="${XDG_CONFIG_HOME:-$HOME/.config}/swaync/images" # For notifications rofi_theme_for_this_script="${XDG_CONFIG_HOME:-$HOME/.config}/rofi/config-kitty-theme.rasi" wallust_refresh_script="${XDG_CONFIG_HOME:-$HOME/.config}/hypr/scripts/WallustSwww.sh" debug_log="${XDG_CACHE_HOME:-$HOME/.cache}/kooldots-kitty-themes.log" +ensure_managed_kitty_config() { + if [ -f "$user_kitty_config" ] && [ -r "$user_kitty_config" ]; then + kitty_config="$user_kitty_config" + return 0 + fi + + if [ -r "$fallback_kitty_config" ]; then + mkdir -p "$(dirname "$user_kitty_config")" 2>/dev/null || true + cp -f "$fallback_kitty_config" "$user_kitty_config" 2>/dev/null || true + if [ -f "$user_kitty_config" ] && [ -r "$user_kitty_config" ]; then + kitty_config="$user_kitty_config" + return 0 + fi + fi + + kitty_config="$fallback_kitty_config" +} + # --- Helper Functions --- notify_user() { notify-send -u low -i "$1" "$2" "$3" @@ -126,6 +146,11 @@ if [ ! -f "$rofi_theme_for_this_script" ]; then notify_user "$iDIR/error.png" "Rofi Config Missing" "Rofi theme for Kitty selector not found at: $rofi_theme_for_this_script." exit 1 fi +ensure_managed_kitty_config +if [ ! -f "$kitty_config" ] || [ ! -r "$kitty_config" ]; then + notify_user "$iDIR/error.png" "E-R-R-O-R" "Kitty config not found: $kitty_config" + exit 1 +fi original_kitty_config_content_backup=$(cat "$kitty_config") diff --git a/scripts/migrate-hypr-to-lua.sh b/scripts/migrate-hypr-to-lua.sh index a3e4c78c..0a127688 100755 --- a/scripts/migrate-hypr-to-lua.sh +++ b/scripts/migrate-hypr-to-lua.sh @@ -53,6 +53,13 @@ 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="" +USER_CONFIGS_PRESERVED_CONFS=( + "kitty.conf" + "ghostty.conf" + "hyprview-layout.conf" + "LaptopDisplay.conf" + "WorkSpaceRules.conf" +) usage() { cat <<USAGE @@ -137,6 +144,8 @@ restore_latest_conf_backup() { local legacy_root="$target_dir/$LEGACY_CONFIGS_DIR_NAME" local moved=0 local file + local basename + local keep local archives=() [ -d "$target_dir" ] || return 0 @@ -2210,13 +2219,27 @@ move_conf_files_to_legacy() { local source_dir="$1" local legacy_dir="$2" local label="$3" + shift 3 + local -a preserved_confs=("$@") local moved=0 local file + local basename + local keep + local preserved [ -d "$source_dir" ] || return 0 mkdir -p "$legacy_dir" while IFS= read -r -d '' file; do + basename="$(basename "$file")" + keep=0 + for preserved in "${preserved_confs[@]}"; do + if [ "$basename" = "$preserved" ]; then + keep=1 + break + fi + done + [ "$keep" -eq 1 ] && continue mv "$file" "$legacy_dir/" moved=1 done < <(find "$source_dir" -maxdepth 1 -type f -name '*.conf' -print0) @@ -2253,11 +2276,11 @@ print_conversion_coverage_summary() { [INFO] - $DEST_HYPR_DIR/hyprlock.conf, hyprlock-1080p.conf, hyprlock-2k.conf [INFO] - $DEST_HYPR_DIR/hyprland.conf (fallback/non-Lua entrypoint) [INFO] - $DEST_HYPR_DIR/Monitor_Profiles/*.conf and $DEST_HYPR_DIR/animations/*.conf (preset profiles) +[INFO] - $USER_CONFIGS_DIR/kitty.conf, $USER_CONFIGS_DIR/ghostty.conf, $USER_CONFIGS_DIR/hyprview-layout.conf [INFO] - $USER_CONFIGS_DIR/LaptopDisplay.conf and $USER_CONFIGS_DIR/WorkSpaceRules.conf (legacy/helper files) SUMMARY } - -move_conf_files_to_legacy "$USER_CONFIGS_DIR" "$USER_CONFIGS_LEGACY_DIR" "$USER_CONFIGS_DIR" +move_conf_files_to_legacy "$USER_CONFIGS_DIR" "$USER_CONFIGS_LEGACY_DIR" "$USER_CONFIGS_DIR" "${USER_CONFIGS_PRESERVED_CONFS[@]}" move_conf_files_to_legacy "$CONFIGS_DIR" "$CONFIGS_LEGACY_DIR" "$CONFIGS_DIR" print_conversion_coverage_summary |
