#!/bin/bash

# 1. Define the target folders here (use absolute or relative paths)
HYPR_CONFIG_FOLDER=".config/hypr/conf"
TARGET_FOLDERS=(
    "$HYPR_CONFIG_FOLDER/animations"
    "$HYPR_CONFIG_FOLDER/decorations"
    "$HYPR_CONFIG_FOLDER/environments"
    "$HYPR_CONFIG_FOLDER/keybindings"
    "$HYPR_CONFIG_FOLDER/layouts"
    "$HYPR_CONFIG_FOLDER/monitors"
    "$HYPR_CONFIG_FOLDER/windowrules"
    "$HYPR_CONFIG_FOLDER/windows"
    "$HYPR_CONFIG_FOLDER/workspaces"
    "$HYPR_CONFIG_FOLDER"
)

echo "Do you want to remove all .conf files from ~/.config/hypr/* that have been replaced with .lua?"
if gum confirm "Do you want to proceed?" ;then
    echo "Starting cleanup of .conf files..."
    echo "-----------------------------------"

    # 2. Loop through each folder in the array
    for folder in "${TARGET_FOLDERS[@]}"; do
        
        # 3. Verify the directory actually exists before trying to modify it
        if [[ -d "$HOME/$folder" ]]; then
            echo "Cleaning: $folder"
            
            # 4. Find and delete the files
            # Note: -maxdepth 1 ensures it only deletes in the target folder, not sub-folders.
            find "$HOME/$folder" -maxdepth 1 -type f -name "*.conf" -exec rm -v {} +
            
        else
            echo "Warning: Directory '$HOME/$folder' not found. Skipping."
        fi
    done

    if [ -f $HOME/.config/hypr/keyboard.conf ]; then
        echo "Cleaning: $HOME/.config/hypr/keyboard.conf"
        rm $HOME/.config/hypr/keyboard.conf
    fi 

    if [ -f $HOME/.config/hypr/hyprland.conf ]; then
        echo "Cleaning: $HOME/.config/hypr/hyprland.conf"
        rm $HOME/.config/hypr/hyprland.conf
    fi 

    echo "-----------------------------------"
    echo "Cleanup complete."
fi