diff options
| author | Donald Williams <129223418+dwilliam62@users.noreply.github.com> | 2025-12-11 12:32:33 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-11 12:32:33 -0500 |
| commit | 1d67791220aacb211a84d90ef030a352e402bd80 (patch) | |
| tree | fc87b1a5e413e906bcc47cf8abf389c2bbd51b71 /config/hypr/scripts | |
| parent | bcfd5e7c2b67f0a62b1ceeb62d20b0a80ca55a70 (diff) | |
| parent | bd5ca3f57c5c2b4a9c8602025cc38e4140b1d5a3 (diff) | |
Merge pull request #881 from JaKooLit/development
Development to main Major update v2.3.18
Diffstat (limited to 'config/hypr/scripts')
| -rwxr-xr-x | config/hypr/scripts/KeyBinds.sh | 95 | ||||
| -rwxr-xr-x | config/hypr/scripts/Kool_Quick_Settings.sh | 57 | ||||
| -rwxr-xr-x | config/hypr/scripts/OverviewToggle.sh | 10 | ||||
| -rwxr-xr-x | config/hypr/scripts/UserConfigsSwitcher.sh | 56 |
4 files changed, 180 insertions, 38 deletions
diff --git a/config/hypr/scripts/KeyBinds.sh b/config/hypr/scripts/KeyBinds.sh index 46953cc5..4158b762 100755 --- a/config/hypr/scripts/KeyBinds.sh +++ b/config/hypr/scripts/KeyBinds.sh @@ -21,9 +21,87 @@ msg='☣️ NOTE ☣️: Clicking with Mouse or Pressing ENTER will have NO func files=("$keybinds_conf" "$user_keybinds_conf") [[ -f "$laptop_conf" ]] && files+=("$laptop_conf") -raw_keybinds=$(cat "${files[@]}" 2>/dev/null \ - | grep -E '^[[:space:]]*bind' \ - | sed -E 's/[[:space:]]+#.*$//') +# Parse binds/unbinds from files, detect overrides, and keep unique effective binds +declare -A binding_map # combo -> bind line (effective) +declare -A source_map # combo -> source file +declare -A user_bind_map # combo -> user bind line +declare -A unbound_user # combo -> 1 if explicitly unbound in user file +declare -A seen_any_bind # combo -> 1 if any bind seen (for iteration) +declare -A default_seen # combo -> 1 if default bind exists +declare -a missing_unbind_suggestions_arr + +normalize_combo() { echo "$1" | sed -E 's/[[:space:]]//g'; } + +extract_combo() { + # arg: a bind/unbind line; returns "mods,key" via echo + local s="$1" + s="$(echo "$s" | sed -E 's/[[:space:]]+#.*$//')" + if [[ "$s" =~ = ]]; then + local rhs="${s#*=}" + local mods="$(echo "$rhs" | awk -F',' '{gsub(/^[ \t]+|[ \t]+$/,"",$1); print $1}')" + local key="$(echo "$rhs" | awk -F',' '{gsub(/^[ \t]+|[ \t]+$/,"",$2); print $2}')" + echo "${mods},${key}" + fi +} + +for file in "${files[@]}"; do + [[ ! -f "$file" ]] && continue + while IFS= read -r line; do + [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue + + if [[ "$line" =~ ^[[:space:]]*bind[a-z]*[[:space:]]*= ]]; then + combo_raw="$(extract_combo "$line")" + [[ -z "$combo_raw" ]] && continue + combo="$(normalize_combo "$combo_raw")" + seen_any_bind["$combo"]=1 + + if [[ "$file" != "$user_keybinds_conf" ]]; then + default_seen["$combo"]=1 + fi + + # prefer user bind, else first seen + if [[ -z "${source_map[$combo]}" ]]; then + binding_map["$combo"]="$line" + source_map["$combo"]="$file" + fi + if [[ "$file" == "$user_keybinds_conf" ]]; then + user_bind_map["$combo"]="$line" + binding_map["$combo"]="$line" + source_map["$combo"]="$file" + fi + + elif [[ "$line" =~ ^[[:space:]]*unbind[[:space:]]*= ]]; then + combo_raw="$(extract_combo "$line")" + [[ -z "$combo_raw" ]] && continue + combo="$(normalize_combo "$combo_raw")" + if [[ "$file" == "$user_keybinds_conf" ]]; then + unbound_user["$combo"]=1 + fi + fi + done < "$file" +done + +# Build raw_keybinds for display and collect missing unbind suggestions +raw_keybinds="" +for combo in "${!seen_any_bind[@]}"; do + eff_line="${binding_map[$combo]}" + src="${source_map[$combo]}" + [[ -z "$eff_line" ]] && continue + raw_keybinds+="$eff_line"$'\n' + + # If user overrides a default but didn't unbind in user file, suggest unbind + if [[ "$src" == "$user_keybinds_conf" && -n "${default_seen[$combo]}" && -z "${unbound_user[$combo]}" ]]; then + suggest="$(echo "$eff_line" | sed -E 's/^[[:space:]]*bind[a-z]*/unbind/')" + missing_unbind_suggestions_arr+=("$suggest") + fi +done + +# If there are missing unbinds, write suggestions to a temp file and note in message +if (( ${#missing_unbind_suggestions_arr[@]} > 0 )); then + suggestions_file="$(mktemp -t hypr-unbind-suggestions.XXXX.conf)" + printf '%s\n' "${missing_unbind_suggestions_arr[@]}" > "$suggestions_file" + msg="$msg | Overrides missing unbind: ${#missing_unbind_suggestions_arr[@]} (suggestions: $suggestions_file)" +fi # check for any keybinds to display if [[ -z "$raw_keybinds" ]]; then @@ -31,7 +109,7 @@ if [[ -z "$raw_keybinds" ]]; then exit 1 fi -# transform into a readable list: MODS+KEY — DESCRIPTION — DISPATCHER [PARAMS] +# transform into a readable list: MODS+KEY — DESCRIPTION (for bindd) or DISPATCHER [PARAMS] (for bind) display_keybinds=$(echo "$raw_keybinds" | awk -F'=' ' function trim(s){ gsub(/^[ \t]+|[ \t]+$/,"",s); return s } /^[[:space:]]*bind/ { @@ -60,13 +138,8 @@ display_keybinds=$(echo "$raw_keybinds" | awk -F'=' ' combo = (mods && key) ? mods "+" key : (key?key:mods); - if (desc != "") { - if (dispatcher != "" && params != "") - print combo, " — ", desc, " — ", dispatcher, " ", params; - else if (dispatcher != "") - print combo, " — ", desc, " — ", dispatcher; - else - print combo, " — ", desc; + if (hasdesc && desc != "") { + print combo, " — ", desc; } else { if (dispatcher != "" && params != "") print combo, " — ", dispatcher, " ", params; diff --git a/config/hypr/scripts/Kool_Quick_Settings.sh b/config/hypr/scripts/Kool_Quick_Settings.sh index 16742492..8ab71ba2 100755 --- a/config/hypr/scripts/Kool_Quick_Settings.sh +++ b/config/hypr/scripts/Kool_Quick_Settings.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # Rofi menu for KooL Hyprland Quick Settings (SUPER SHIFT E) +# Updated for UserConfigs/configs separation # Modify this config file for default terminal and EDITOR config_file="$HOME/.config/hypr/UserConfigs/01-UserDefaults.conf" @@ -19,19 +20,30 @@ iDIR="$HOME/.config/swaync/images" scriptsDir="$HOME/.config/hypr/scripts" UserScripts="$HOME/.config/hypr/UserScripts" +# Function to show info notification +show_info() { + notify-send -i "$iDIR/info.png" "Info" "$1" +} + # Function to display the menu options without numbers menu() { cat <<EOF -view/edit User Defaults -view/edit ENV variables -view/edit Window Rules -view/edit User Keybinds -view/edit User Settings -view/edit Startup Apps -view/edit Decorations -view/edit Animations -view/edit Laptop Keybinds -view/edit Default Keybinds +--- USER CUSTOMIZATIONS --- +Edit User Defaults +Edit User Keybinds +Edit User ENV variables +Edit User Startup Apps (overlay) +Edit User Window Rules (overlay) +Edit User Settings +Edit User Decorations +Edit User Animations +Edit User Laptop Settings +--- SYSTEM DEFAULTS --- +Edit System Default Keybinds +Edit System Default Startup Apps +Edit System Default Window Rules +Edit System Default Settings +--- UTILITIES --- Choose Kitty Terminal Theme Configure Monitors (nwg-displays) Configure Workspace Rules (nwg-displays) @@ -53,16 +65,19 @@ main() { # Map choices to corresponding files case "$choice" in - "view/edit User Defaults") file="$UserConfigs/01-UserDefaults.conf" ;; - "view/edit ENV variables") file="$UserConfigs/ENVariables.conf" ;; - "view/edit Window Rules") file="$configs/WindowRules.conf" ;; - "view/edit User Keybinds") file="$UserConfigs/UserKeybinds.conf" ;; - "view/edit User Settings") file="$UserConfigs/UserSettings.conf" ;; - "view/edit Startup Apps") file="$configs/Startup_Apps.conf" ;; - "view/edit Decorations") file="$UserConfigs/UserDecorations.conf" ;; - "view/edit Animations") file="$UserConfigs/UserAnimations.conf" ;; - "view/edit Laptop Keybinds") file="$UserConfigs/Laptops.conf" ;; - "view/edit Default Keybinds") file="$configs/Keybinds.conf" ;; + "Edit User Defaults") file="$UserConfigs/01-UserDefaults.conf" ;; + "Edit User ENV variables") file="$UserConfigs/ENVariables.conf" ;; + "Edit User Keybinds") file="$UserConfigs/UserKeybinds.conf" ;; + "Edit User Startup Apps (overlay)") file="$UserConfigs/Startup_Apps.conf" ;; + "Edit User Window Rules (overlay)") file="$UserConfigs/WindowRules.conf" ;; + "Edit User Settings") file="$configs/SystemSettings.conf"; show_info "Editing default settings. Copy to UserConfigs/UserSettings.conf to override." ;; + "Edit User Decorations") file="$UserConfigs/UserDecorations.conf" ;; + "Edit User Animations") file="$UserConfigs/UserAnimations.conf" ;; + "Edit User Laptop Settings") file="$UserConfigs/Laptops.conf" ;; + "Edit System Default Keybinds") file="$configs/Keybinds.conf" ;; + "Edit System Default Startup Apps") file="$configs/Startup_Apps.conf" ;; + "Edit System Default Window Rules") file="$configs/WindowRules.conf" ;; + "Edit System Default Settings") file="$configs/SystemSettings.conf" ;; "Choose Kitty Terminal Theme") $scriptsDir/Kitty_themes.sh ;; "Configure Monitors (nwg-displays)") if ! command -v nwg-displays &>/dev/null; then @@ -114,4 +129,4 @@ if pidof rofi > /dev/null; then pkill rofi fi -main
\ No newline at end of file +main diff --git a/config/hypr/scripts/OverviewToggle.sh b/config/hypr/scripts/OverviewToggle.sh index 2737234c..8d4b285f 100755 --- a/config/hypr/scripts/OverviewToggle.sh +++ b/config/hypr/scripts/OverviewToggle.sh @@ -4,20 +4,18 @@ set -euo pipefail -# 1) Try Quickshell via Hyprland global dispatch (works if QS is running and listening) -# Only attempt this if a Quickshell process is running; otherwise Hyprland will -# still return success for the dispatch and we'll never fall back to AGS. +# 1) Try Quickshell via IPC (works if QS is running and listening) if pgrep -x quickshell >/dev/null 2>&1; then - if hyprctl dispatch global quickshell:overviewToggle >/dev/null 2>&1; then + if qs ipc -c overview call overview toggle >/dev/null 2>&1; then exit 0 fi fi # If QS isn't running, but the CLI exists, try starting it and retry once if command -v qs >/dev/null 2>&1; then - qs >/dev/null 2>&1 & + qs -c overview >/dev/null 2>&1 & sleep 0.6 - if hyprctl dispatch global quickshell:overviewToggle >/dev/null 2>&1; then + if qs ipc -c overview call overview toggle >/dev/null 2>&1; then exit 0 fi fi diff --git a/config/hypr/scripts/UserConfigsSwitcher.sh b/config/hypr/scripts/UserConfigsSwitcher.sh new file mode 100755 index 00000000..ad1d4e63 --- /dev/null +++ b/config/hypr/scripts/UserConfigsSwitcher.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## +# Script to manage UserConfigs and UserConfigsBak + +HYPR_CONFIG_DIR="$HOME/.config/hypr" +USER_CONFIGS="$HYPR_CONFIG_DIR/UserConfigs" +USER_CONFIGS_BAK="$HYPR_CONFIG_DIR/UserConfigsBak" + +if [ -d "$USER_CONFIGS" ] && [ ! -d "$USER_CONFIGS_BAK" ]; then + echo "Moving UserConfigs to UserConfigsBak..." + mv "$USER_CONFIGS" "$USER_CONFIGS_BAK" + echo "Done. Your UserConfigs are now in UserConfigsBak." +elif [ ! -d "$USER_CONFIGS" ] && [ -d "$USER_CONFIGS_BAK" ]; then + echo "Moving UserConfigsBak to UserConfigs..." + mv "$USER_CONFIGS_BAK" "$USER_CONFIGS" + echo "Done. Your backup has been restored to UserConfigs." +elif [ -d "$USER_CONFIGS" ] && [ -d "$USER_CONFIGS_BAK" ]; then + echo "Both UserConfigs and UserConfigsBak exist." + echo "Please choose what to do:" + PS3="Enter your choice: " + select option in "Backup current UserConfigs (move to UserConfigsBak)" "Restore backup (move UserConfigsBak to UserConfigs)" "Swap them" "Do nothing"; do + case $REPLY in + 1) + echo "Backing up UserConfigs..." + rm -rf "$USER_CONFIGS_BAK" + mv "$USER_CONFIGS" "$USER_CONFIGS_BAK" + echo "Done. UserConfigs moved to UserConfigsBak." + break + ;; + 2) + echo "Restoring backup..." + rm -rf "$USER_CONFIGS" + mv "$USER_CONFIGS_BAK" "$USER_CONFIGS" + echo "Done. UserConfigsBak moved to UserConfigs." + break + ;; + 3) + echo "Swapping..." + mv "$USER_CONFIGS" "$HYPR_CONFIG_DIR/UserConfigs.tmp" + mv "$USER_CONFIGS_BAK" "$USER_CONFIGS" + mv "$HYPR_CONFIG_DIR/UserConfigs.tmp" "$USER_CONFIGS_BAK" + echo "Done. UserConfigs and UserConfigsBak have been swapped." + break + ;; + 4) + echo "No changes made." + break + ;; + *) + echo "Invalid option. Please try again." + ;; + esac + done +else + echo "Neither UserConfigs nor UserConfigsBak directory found. Nothing to do." +fi |
