From 4fa6d3b1c539492c852527698f97f74b723ef473 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Feb 2026 04:37:04 +0000 Subject: [PATCH 1/3] feat(hyprland): add Alt+Tab window switching with focus history Add a focus-history-based Alt+Tab window switcher for Hyprland, inspired by the saneAspect tutorial. Uses hyprctl to cycle windows by recency (like Windows/macOS), with session-aware state persistence for continuous switching, reverse cycling (ALT+Shift+Tab), and temporary dim feedback. https://claude.ai/code/session_01NNjd5QrBK887SPA9wLsBZx --- config/hyprland/default.nix | 5 + config/hyprland/hyprland.conf | 4 + config/hyprland/scripts/alt-tab.sh | 259 +++++++++++++++++++++++++++++ home-manager/packages/default.nix | 1 + 4 files changed, 269 insertions(+) create mode 100644 config/hyprland/scripts/alt-tab.sh diff --git a/config/hyprland/default.nix b/config/hyprland/default.nix index 26e229ec3..a0553a42c 100644 --- a/config/hyprland/default.nix +++ b/config/hyprland/default.nix @@ -38,4 +38,9 @@ in executable = true; force = true; }; + xdg.configFile."hypr/scripts/alt-tab.sh" = { + source = ./scripts/alt-tab.sh; + executable = true; + force = true; + }; } diff --git a/config/hyprland/hyprland.conf b/config/hyprland/hyprland.conf index da0efddda..2b2149590 100644 --- a/config/hyprland/hyprland.conf +++ b/config/hyprland/hyprland.conf @@ -354,6 +354,10 @@ bindm = $mod, mouse:273, resizewindow bind = $mod CTRL, T, exec, ~/.config/hypr/scripts/toggle-terminal.sh bind = $mod SHIFT, R, exec, ~/.config/hypr/scripts/record-screen.sh +# Alt+Tab window switching (focus-history based, like Windows/macOS) +bind = ALT, Tab, exec, ~/.config/hypr/scripts/alt-tab.sh +bind = ALT SHIFT, Tab, exec, ~/.config/hypr/scripts/alt-tab.sh --reverse + # Quick previous-window toggle (like macOS Cmd+`) bind = $mod, GRAVE, focuscurrentorlast diff --git a/config/hyprland/scripts/alt-tab.sh b/config/hyprland/scripts/alt-tab.sh new file mode 100644 index 000000000..7cbaa743e --- /dev/null +++ b/config/hyprland/scripts/alt-tab.sh @@ -0,0 +1,259 @@ +#!/bin/bash + +STATE_DIR="/tmp/hypr-alt-tab" +STATE_FILE="$STATE_DIR/state" +TIME_FILE="$STATE_DIR/last_press" +CURRENT_INDEX_FILE="$STATE_DIR/current_index" +WINDOW_LIST_FILE="$STATE_DIR/window_list" + +# Cooldown in seconds (time within which presses count as "continuous") +COOLDOWN=0.8 + +# Create state directory if it doesn't exist +mkdir -p "$STATE_DIR" + +# Parse arguments +same_type=false +reverse=false +visible_only=false + +for arg in "$@"; do + case $arg in + --same) same_type=true ;; + --reverse) reverse=true ;; + --visible) visible_only=true ;; + esac +done + +# Function to get window class +get_window_class() { + local window="$1" + hyprctl clients -j | jq -r --arg addr "$window" '.[] | select(.address == $addr) | .class' +} + +# Function to get window title +get_window_title() { + local window="$1" + hyprctl clients -j | jq -r --arg addr "$window" '.[] | select(.address == $addr) | .title' +} + +# Function to get window workspace ID +get_window_workspace() { + local window="$1" + hyprctl clients -j | jq -r --arg addr "$window" '.[] | select(.address == $addr) | .workspace.id' +} + +# Function to get active workspaces (visible on monitors) +get_active_workspaces() { + hyprctl monitors -j | jq -r '.[].activeWorkspace.id' +} + +# Function to get all windows sorted by focus history (most recent first) +get_windows_by_focus() { + hyprctl clients -j | jq -r 'sort_by(-.focusHistoryID) | .[].address' +} + +# Function to get visible windows (on active workspaces) +get_visible_windows() { + # Get all active workspace IDs + mapfile -t active_workspaces < <(get_active_workspaces) + + if [[ ${#active_workspaces[@]} -eq 0 ]]; then + return + fi + + # Convert active workspaces to JSON array for jq query + local workspaces_json="[" + for ws in "${active_workspaces[@]}"; do + workspaces_json+="$ws," + done + workspaces_json="${workspaces_json%,}]" + + # Get windows in active workspaces, sorted by focus history + hyprctl clients -j | jq -r --argjson workspaces "$workspaces_json" ' + [.[] | select(.workspace.id as $ws | $workspaces | index($ws))] + | sort_by(-.focusHistoryID) + | .[].address + ' +} + +# Function to get windows filtered by type (same class) +get_same_type_windows() { + local current_window="$1" + local current_class + current_class=$(get_window_class "$current_window") + + # Get all windows with same class + hyprctl clients -j | jq -r --arg class "$current_class" \ + '.[] | select(.class == $class) | .address' +} + +# Function to get currently focused window +get_focused_window() { + hyprctl activewindow -j | jq -r '.address' +} + +# Function to check if window exists +window_exists() { + local window="$1" + [[ -n "$window" ]] && hyprctl clients -j | jq -r '.[].address' | grep -q "^${window}$" +} + +# Function to validate and refresh window list +validate_window_list() { + local windows=("$@") + local valid_windows=() + + for window in "${windows[@]}"; do + if window_exists "$window"; then + valid_windows+=("$window") + fi + done + + printf '%s\n' "${valid_windows[@]}" +} + +# Get currently focused window +current_focused=$(get_focused_window) + +# Get appropriate window list based on mode +if [[ "$visible_only" == "true" ]]; then + mapfile -t windows < <(get_visible_windows) + + # If no visible windows, fall back to all windows + if [[ ${#windows[@]} -eq 0 ]]; then + mapfile -t windows < <(get_windows_by_focus) + fi + + # Apply same-type filter if requested + if [[ "$same_type" == "true" ]] && [[ -n "$current_focused" ]]; then + mapfile -t same_type_windows < <(get_same_type_windows "$current_focused") + + local filtered_windows=() + for visible_window in "${windows[@]}"; do + for same_window in "${same_type_windows[@]}"; do + if [[ "$visible_window" == "$same_window" ]]; then + filtered_windows+=("$visible_window") + break + fi + done + done + + if [[ ${#filtered_windows[@]} -gt 0 ]]; then + windows=("${filtered_windows[@]}") + fi + fi +elif [[ "$same_type" == "true" ]] && [[ -n "$current_focused" ]]; then + mapfile -t windows < <(get_same_type_windows "$current_focused") + + # If no same-type windows or only current window, fall back to all windows + if [[ ${#windows[@]} -le 1 ]]; then + mapfile -t windows < <(get_windows_by_focus) + fi +else + mapfile -t windows < <(get_windows_by_focus) +fi + +# Validate windows still exist +mapfile -t windows < <(validate_window_list "${windows[@]}") + +# Exit if no windows or only one window +if [[ ${#windows[@]} -le 1 ]]; then + exit 0 +fi + +# Get current time +current_time=$(date +%s.%N) + +# Read last press time +last_press=0 +[[ -f "$TIME_FILE" ]] && last_press=$(<"$TIME_FILE") + +# Calculate time difference +time_diff=$(echo "$current_time - $last_press" | bc -l 2>/dev/null || echo "1") + +# Check if we're continuing the Alt+Tab session +continuing_session=false +if (( $(echo "$time_diff <= $COOLDOWN" | bc -l 2>/dev/null || echo "0") )); then + continuing_session=true +fi + +# Find current window index in the list +current_index=-1 +for i in "${!windows[@]}"; do + if [[ "${windows[$i]}" == "$current_focused" ]]; then + current_index=$i + break + fi +done + +# If current window not in filtered list, start from beginning +if [[ $current_index -eq -1 ]]; then + current_index=0 +fi + +# Calculate target index +if [[ "$continuing_session" == "true" ]] && [[ -f "$CURRENT_INDEX_FILE" ]] && [[ -f "$WINDOW_LIST_FILE" ]]; then + # Read saved state + saved_index=$(<"$CURRENT_INDEX_FILE") + mapfile -t saved_windows < "$WINDOW_LIST_FILE" + + # Check if saved windows match current windows + same_list=true + if [[ ${#windows[@]} -ne ${#saved_windows[@]} ]]; then + same_list=false + else + for i in "${!windows[@]}"; do + if [[ "${windows[$i]}" != "${saved_windows[$i]}" ]]; then + same_list=false + break + fi + done + fi + + if [[ "$same_list" == "true" ]]; then + if [[ "$reverse" == "true" ]]; then + target_index=$(( (saved_index - 1 + ${#windows[@]}) % ${#windows[@]} )) + else + target_index=$(( (saved_index + 1) % ${#windows[@]} )) + fi + else + if [[ "$reverse" == "true" ]]; then + target_index=$(( (current_index - 1 + ${#windows[@]}) % ${#windows[@]} )) + else + target_index=$(( (current_index + 1) % ${#windows[@]} )) + fi + fi +else + # Start new session - move from current window + if [[ "$reverse" == "true" ]]; then + target_index=$(( (current_index - 1 + ${#windows[@]}) % ${#windows[@]} )) + else + target_index=$(( (current_index + 1) % ${#windows[@]} )) + fi +fi + +# Save state +echo "$current_time" > "$TIME_FILE" +echo "$target_index" > "$CURRENT_INDEX_FILE" +printf '%s\n' "${windows[@]}" > "$WINDOW_LIST_FILE" + +# Focus the target window +target_window="${windows[$target_index]}" +if window_exists "$target_window"; then + hyprctl dispatch focuswindow "address:$target_window" + hyprctl dispatch alterzorder top +fi + +# Visual feedback: dim inactive windows temporarily +hyprctl keyword decoration:dim_inactive true 2>/dev/null + +# Clear any existing reset timer +[[ -f "$STATE_DIR/dim_timer" ]] && kill "$(<"$STATE_DIR/dim_timer")" 2>/dev/null || true + +# Start timer to reset dimming +( + sleep 1.2 + hyprctl keyword decoration:dim_inactive false 2>/dev/null +) & +echo $! > "$STATE_DIR/dim_timer" diff --git a/home-manager/packages/default.nix b/home-manager/packages/default.nix index 2e3905dbd..027c8808d 100644 --- a/home-manager/packages/default.nix +++ b/home-manager/packages/default.nix @@ -16,6 +16,7 @@ with pkgs; awscli azure-cli bat + bc broot bun clipse From 14e42d97a7956b439703f1b840ea0c88aba58188 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Feb 2026 05:02:08 +0000 Subject: [PATCH 2/3] feat(hyprland): replace Super+Tab with snappy-switcher window switcher Use snappy-switcher (OpalAayan/snappy-switcher) for Super+Tab instead of hyprexpo. Adds daemon startup, Dracula-themed config, and Super+Shift+Tab for reverse cycling. https://claude.ai/code/session_01NNjd5QrBK887SPA9wLsBZx --- config/hyprland/default.nix | 7 +++++++ config/hyprland/hyprland.conf | 3 ++- config/hyprland/snappy-switcher-config.ini | 20 ++++++++++++++++++++ flake.nix | 3 +++ home-manager/packages/default.nix | 1 + 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 config/hyprland/snappy-switcher-config.ini diff --git a/config/hyprland/default.nix b/config/hyprland/default.nix index a0553a42c..fb3916aef 100644 --- a/config/hyprland/default.nix +++ b/config/hyprland/default.nix @@ -6,6 +6,7 @@ }: let hyprexpoPlugin = pkgs.hyprlandPlugins.hyprexpo; + snappySwitcher = inputs.snappy-switcher.packages.${pkgs.stdenv.hostPlatform.system}.default; in { wayland.windowManager.hyprland = { @@ -15,6 +16,7 @@ in extraConfig = '' plugin = ${hyprexpoPlugin}/lib/libhyprexpo.so exec-once = ${pkgs.hyprpanel}/bin/hyprpanel + exec-once = ${snappySwitcher}/bin/snappy-switcher --daemon '' + builtins.readFile ./hyprland.conf; }; @@ -43,4 +45,9 @@ in executable = true; force = true; }; + + xdg.configFile."snappy-switcher/config.ini" = { + source = ./snappy-switcher-config.ini; + force = true; + }; } diff --git a/config/hyprland/hyprland.conf b/config/hyprland/hyprland.conf index 2b2149590..346a69c6c 100644 --- a/config/hyprland/hyprland.conf +++ b/config/hyprland/hyprland.conf @@ -258,7 +258,8 @@ bind = $mod SHIFT, F, togglefloating, bind = CTRL ALT SHIFT SUPER, F, exec, hyprctl --batch "dispatch movetoworkspace empty; dispatch fullscreen 0" bind = SUPER CTRL, F, fullscreen, 1 bind = $mod SHIFT, Q, exec, hyprpanel toggleWindow power-menu -bind = $mod, TAB, hyprexpo:expo, toggle +bind = $mod, TAB, exec, snappy-switcher next +bind = $mod SHIFT, TAB, exec, snappy-switcher prev # Focus (vim keys) bind = $mod, H, movefocus, l diff --git a/config/hyprland/snappy-switcher-config.ini b/config/hyprland/snappy-switcher-config.ini new file mode 100644 index 000000000..0ee11cf57 --- /dev/null +++ b/config/hyprland/snappy-switcher-config.ini @@ -0,0 +1,20 @@ +[general] +mode = context + +[theme] +name = dracula.ini +border_width = 3 +corner_radius = 8 + +[layout] +card_width = 160 +card_height = 140 +card_gap = 10 +padding = 20 +max_cols = 5 +icon_size = 56 + +[font] +family = Sans +weight = Bold +title_size = 10 diff --git a/flake.nix b/flake.nix index 53fc836cb..540adeceb 100644 --- a/flake.nix +++ b/flake.nix @@ -64,6 +64,9 @@ url = "github:xremap/nix-flake"; inputs.nixpkgs.follows = "nixpkgs"; }; + snappy-switcher = { + url = "github:OpalAayan/snappy-switcher"; + }; }; outputs = diff --git a/home-manager/packages/default.nix b/home-manager/packages/default.nix index 027c8808d..e8e652cfb 100644 --- a/home-manager/packages/default.nix +++ b/home-manager/packages/default.nix @@ -120,6 +120,7 @@ with pkgs; xclip ] ++ lib.optionals (stdenv.isLinux && isDesktop) [ + inputs.snappy-switcher.packages.${stdenv.hostPlatform.system}.default _1password-gui brightnessctl chromium From 02988f9a265469ed8a39224a9770fe49d0b46dfb Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Feb 2026 05:25:32 +0000 Subject: [PATCH 3/3] refactor: move snappy-switcher config to own module, delete alt-tab.sh - Move snappy-switcher config from config/hyprland/ to config/snappy-switcher/ with its own default.nix module (matching repo convention) - Delete config/hyprland/scripts/alt-tab.sh (replaced by snappy-switcher) - Remove alt-tab.sh bindings and xdg.configFile entries from hyprland config https://claude.ai/code/session_01NNjd5QrBK887SPA9wLsBZx --- config/default.nix | 1 + config/hyprland/default.nix | 10 - config/hyprland/hyprland.conf | 4 - config/hyprland/scripts/alt-tab.sh | 259 ------------------ .../config.ini} | 0 config/snappy-switcher/default.nix | 7 + 6 files changed, 8 insertions(+), 273 deletions(-) delete mode 100644 config/hyprland/scripts/alt-tab.sh rename config/{hyprland/snappy-switcher-config.ini => snappy-switcher/config.ini} (100%) create mode 100644 config/snappy-switcher/default.nix diff --git a/config/default.nix b/config/default.nix index 7d415b27e..f319131a6 100644 --- a/config/default.nix +++ b/config/default.nix @@ -37,6 +37,7 @@ in ./hyprland ./hyprpanel ./rofi + ./snappy-switcher ] else [ ] diff --git a/config/hyprland/default.nix b/config/hyprland/default.nix index fb3916aef..f91222b60 100644 --- a/config/hyprland/default.nix +++ b/config/hyprland/default.nix @@ -40,14 +40,4 @@ in executable = true; force = true; }; - xdg.configFile."hypr/scripts/alt-tab.sh" = { - source = ./scripts/alt-tab.sh; - executable = true; - force = true; - }; - - xdg.configFile."snappy-switcher/config.ini" = { - source = ./snappy-switcher-config.ini; - force = true; - }; } diff --git a/config/hyprland/hyprland.conf b/config/hyprland/hyprland.conf index 346a69c6c..6ac9fa126 100644 --- a/config/hyprland/hyprland.conf +++ b/config/hyprland/hyprland.conf @@ -355,10 +355,6 @@ bindm = $mod, mouse:273, resizewindow bind = $mod CTRL, T, exec, ~/.config/hypr/scripts/toggle-terminal.sh bind = $mod SHIFT, R, exec, ~/.config/hypr/scripts/record-screen.sh -# Alt+Tab window switching (focus-history based, like Windows/macOS) -bind = ALT, Tab, exec, ~/.config/hypr/scripts/alt-tab.sh -bind = ALT SHIFT, Tab, exec, ~/.config/hypr/scripts/alt-tab.sh --reverse - # Quick previous-window toggle (like macOS Cmd+`) bind = $mod, GRAVE, focuscurrentorlast diff --git a/config/hyprland/scripts/alt-tab.sh b/config/hyprland/scripts/alt-tab.sh deleted file mode 100644 index 7cbaa743e..000000000 --- a/config/hyprland/scripts/alt-tab.sh +++ /dev/null @@ -1,259 +0,0 @@ -#!/bin/bash - -STATE_DIR="/tmp/hypr-alt-tab" -STATE_FILE="$STATE_DIR/state" -TIME_FILE="$STATE_DIR/last_press" -CURRENT_INDEX_FILE="$STATE_DIR/current_index" -WINDOW_LIST_FILE="$STATE_DIR/window_list" - -# Cooldown in seconds (time within which presses count as "continuous") -COOLDOWN=0.8 - -# Create state directory if it doesn't exist -mkdir -p "$STATE_DIR" - -# Parse arguments -same_type=false -reverse=false -visible_only=false - -for arg in "$@"; do - case $arg in - --same) same_type=true ;; - --reverse) reverse=true ;; - --visible) visible_only=true ;; - esac -done - -# Function to get window class -get_window_class() { - local window="$1" - hyprctl clients -j | jq -r --arg addr "$window" '.[] | select(.address == $addr) | .class' -} - -# Function to get window title -get_window_title() { - local window="$1" - hyprctl clients -j | jq -r --arg addr "$window" '.[] | select(.address == $addr) | .title' -} - -# Function to get window workspace ID -get_window_workspace() { - local window="$1" - hyprctl clients -j | jq -r --arg addr "$window" '.[] | select(.address == $addr) | .workspace.id' -} - -# Function to get active workspaces (visible on monitors) -get_active_workspaces() { - hyprctl monitors -j | jq -r '.[].activeWorkspace.id' -} - -# Function to get all windows sorted by focus history (most recent first) -get_windows_by_focus() { - hyprctl clients -j | jq -r 'sort_by(-.focusHistoryID) | .[].address' -} - -# Function to get visible windows (on active workspaces) -get_visible_windows() { - # Get all active workspace IDs - mapfile -t active_workspaces < <(get_active_workspaces) - - if [[ ${#active_workspaces[@]} -eq 0 ]]; then - return - fi - - # Convert active workspaces to JSON array for jq query - local workspaces_json="[" - for ws in "${active_workspaces[@]}"; do - workspaces_json+="$ws," - done - workspaces_json="${workspaces_json%,}]" - - # Get windows in active workspaces, sorted by focus history - hyprctl clients -j | jq -r --argjson workspaces "$workspaces_json" ' - [.[] | select(.workspace.id as $ws | $workspaces | index($ws))] - | sort_by(-.focusHistoryID) - | .[].address - ' -} - -# Function to get windows filtered by type (same class) -get_same_type_windows() { - local current_window="$1" - local current_class - current_class=$(get_window_class "$current_window") - - # Get all windows with same class - hyprctl clients -j | jq -r --arg class "$current_class" \ - '.[] | select(.class == $class) | .address' -} - -# Function to get currently focused window -get_focused_window() { - hyprctl activewindow -j | jq -r '.address' -} - -# Function to check if window exists -window_exists() { - local window="$1" - [[ -n "$window" ]] && hyprctl clients -j | jq -r '.[].address' | grep -q "^${window}$" -} - -# Function to validate and refresh window list -validate_window_list() { - local windows=("$@") - local valid_windows=() - - for window in "${windows[@]}"; do - if window_exists "$window"; then - valid_windows+=("$window") - fi - done - - printf '%s\n' "${valid_windows[@]}" -} - -# Get currently focused window -current_focused=$(get_focused_window) - -# Get appropriate window list based on mode -if [[ "$visible_only" == "true" ]]; then - mapfile -t windows < <(get_visible_windows) - - # If no visible windows, fall back to all windows - if [[ ${#windows[@]} -eq 0 ]]; then - mapfile -t windows < <(get_windows_by_focus) - fi - - # Apply same-type filter if requested - if [[ "$same_type" == "true" ]] && [[ -n "$current_focused" ]]; then - mapfile -t same_type_windows < <(get_same_type_windows "$current_focused") - - local filtered_windows=() - for visible_window in "${windows[@]}"; do - for same_window in "${same_type_windows[@]}"; do - if [[ "$visible_window" == "$same_window" ]]; then - filtered_windows+=("$visible_window") - break - fi - done - done - - if [[ ${#filtered_windows[@]} -gt 0 ]]; then - windows=("${filtered_windows[@]}") - fi - fi -elif [[ "$same_type" == "true" ]] && [[ -n "$current_focused" ]]; then - mapfile -t windows < <(get_same_type_windows "$current_focused") - - # If no same-type windows or only current window, fall back to all windows - if [[ ${#windows[@]} -le 1 ]]; then - mapfile -t windows < <(get_windows_by_focus) - fi -else - mapfile -t windows < <(get_windows_by_focus) -fi - -# Validate windows still exist -mapfile -t windows < <(validate_window_list "${windows[@]}") - -# Exit if no windows or only one window -if [[ ${#windows[@]} -le 1 ]]; then - exit 0 -fi - -# Get current time -current_time=$(date +%s.%N) - -# Read last press time -last_press=0 -[[ -f "$TIME_FILE" ]] && last_press=$(<"$TIME_FILE") - -# Calculate time difference -time_diff=$(echo "$current_time - $last_press" | bc -l 2>/dev/null || echo "1") - -# Check if we're continuing the Alt+Tab session -continuing_session=false -if (( $(echo "$time_diff <= $COOLDOWN" | bc -l 2>/dev/null || echo "0") )); then - continuing_session=true -fi - -# Find current window index in the list -current_index=-1 -for i in "${!windows[@]}"; do - if [[ "${windows[$i]}" == "$current_focused" ]]; then - current_index=$i - break - fi -done - -# If current window not in filtered list, start from beginning -if [[ $current_index -eq -1 ]]; then - current_index=0 -fi - -# Calculate target index -if [[ "$continuing_session" == "true" ]] && [[ -f "$CURRENT_INDEX_FILE" ]] && [[ -f "$WINDOW_LIST_FILE" ]]; then - # Read saved state - saved_index=$(<"$CURRENT_INDEX_FILE") - mapfile -t saved_windows < "$WINDOW_LIST_FILE" - - # Check if saved windows match current windows - same_list=true - if [[ ${#windows[@]} -ne ${#saved_windows[@]} ]]; then - same_list=false - else - for i in "${!windows[@]}"; do - if [[ "${windows[$i]}" != "${saved_windows[$i]}" ]]; then - same_list=false - break - fi - done - fi - - if [[ "$same_list" == "true" ]]; then - if [[ "$reverse" == "true" ]]; then - target_index=$(( (saved_index - 1 + ${#windows[@]}) % ${#windows[@]} )) - else - target_index=$(( (saved_index + 1) % ${#windows[@]} )) - fi - else - if [[ "$reverse" == "true" ]]; then - target_index=$(( (current_index - 1 + ${#windows[@]}) % ${#windows[@]} )) - else - target_index=$(( (current_index + 1) % ${#windows[@]} )) - fi - fi -else - # Start new session - move from current window - if [[ "$reverse" == "true" ]]; then - target_index=$(( (current_index - 1 + ${#windows[@]}) % ${#windows[@]} )) - else - target_index=$(( (current_index + 1) % ${#windows[@]} )) - fi -fi - -# Save state -echo "$current_time" > "$TIME_FILE" -echo "$target_index" > "$CURRENT_INDEX_FILE" -printf '%s\n' "${windows[@]}" > "$WINDOW_LIST_FILE" - -# Focus the target window -target_window="${windows[$target_index]}" -if window_exists "$target_window"; then - hyprctl dispatch focuswindow "address:$target_window" - hyprctl dispatch alterzorder top -fi - -# Visual feedback: dim inactive windows temporarily -hyprctl keyword decoration:dim_inactive true 2>/dev/null - -# Clear any existing reset timer -[[ -f "$STATE_DIR/dim_timer" ]] && kill "$(<"$STATE_DIR/dim_timer")" 2>/dev/null || true - -# Start timer to reset dimming -( - sleep 1.2 - hyprctl keyword decoration:dim_inactive false 2>/dev/null -) & -echo $! > "$STATE_DIR/dim_timer" diff --git a/config/hyprland/snappy-switcher-config.ini b/config/snappy-switcher/config.ini similarity index 100% rename from config/hyprland/snappy-switcher-config.ini rename to config/snappy-switcher/config.ini diff --git a/config/snappy-switcher/default.nix b/config/snappy-switcher/default.nix new file mode 100644 index 000000000..7c4f80200 --- /dev/null +++ b/config/snappy-switcher/default.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + xdg.configFile."snappy-switcher/config.ini" = { + source = ./config.ini; + force = true; + }; +}