From 7612539f21326332250c906cdf78fdb97bec9a1c Mon Sep 17 00:00:00 2001 From: Don Williams Date: Tue, 23 Dec 2025 23:17:12 -0500 Subject: Switch KB layout updated for new location System settings move to hypr/configs/Systemsettings On branch development Your branch is up to date with 'origin/development'. Changes to be committed: modified: CHANGELOG.md modified: config/hypr/scripts/SwitchKeyboardLayout.sh modified: config/hypr/scripts/Tak0-Per-Window-Switch.sh --- config/hypr/scripts/Tak0-Per-Window-Switch.sh | 33 +++++++++++++-------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'config/hypr/scripts/Tak0-Per-Window-Switch.sh') diff --git a/config/hypr/scripts/Tak0-Per-Window-Switch.sh b/config/hypr/scripts/Tak0-Per-Window-Switch.sh index 76b6ad2d..7879fb85 100755 --- a/config/hypr/scripts/Tak0-Per-Window-Switch.sh +++ b/config/hypr/scripts/Tak0-Per-Window-Switch.sh @@ -1,5 +1,5 @@ ################################################################## -# # +# # # # # TAK_0'S Per-Window-Switch # # # @@ -7,21 +7,14 @@ # # # Just a little script that I made to switch keyboard layouts # # per-window instead of global switching for the more # -# smooth and comfortable workflow. # +# smooth and comfortable workflow. # # # ################################################################## - - - - - - - -# This is for changing kb_layouts. Set kb_layouts in +# This is for changing kb_layouts. Set kb_layouts in MAP_FILE="$HOME/.cache/kb_layout_per_window" -CFG_FILE="$HOME/.config/hypr/UserConfigs/UserSettings.conf" +CFG_FILE="$HOME/.config/hypr/configs/SystemSettings.conf" ICON="$HOME/.config/swaync/images/ja.png" SCRIPT_NAME="$(basename "$0")" @@ -49,8 +42,8 @@ get_keyboards() { # Save window-specific layout save_map() { local W=$1 L=$2 - grep -v "^${W}:" "$MAP_FILE" > "$MAP_FILE.tmp" - echo "${W}:${L}" >> "$MAP_FILE.tmp" + grep -v "^${W}:" "$MAP_FILE" >"$MAP_FILE.tmp" + echo "${W}:${L}" >>"$MAP_FILE.tmp" mv "$MAP_FILE.tmp" "$MAP_FILE" } @@ -82,7 +75,7 @@ cmd_toggle() { break fi done - NEXT=$(( (i+1) % count )) + NEXT=$(((i + 1) % count)) do_switch "$NEXT" save_map "$W" "${kb_layouts[NEXT]}" notify-send -u low -i "$ICON" "kb_layout: ${kb_layouts[NEXT]}" @@ -104,7 +97,10 @@ cmd_restore() { # Listen to focus events and restore window-specific layouts subscribe() { local SOCKET2="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" - [[ -S "$SOCKET2" ]] || { echo "Error: Hyprland socket not found." >&2; exit 1; } + [[ -S "$SOCKET2" ]] || { + echo "Error: Hyprland socket not found." >&2 + exit 1 + } socat -u UNIX-CONNECT:"$SOCKET2" - | while read -r line; do [[ "$line" =~ ^activewindow ]] && cmd_restore @@ -118,6 +114,9 @@ fi # CLI case "$1" in - toggle|"") cmd_toggle ;; - *) echo "Usage: $SCRIPT_NAME [toggle]" >&2; exit 1 ;; +toggle | "") cmd_toggle ;; +*) + echo "Usage: $SCRIPT_NAME [toggle]" >&2 + exit 1 + ;; esac -- cgit v1.2.3 From 3a423138021325a6d97ab0538625305795a6b1c1 Mon Sep 17 00:00:00 2001 From: Don Williams Date: Thu, 8 Jan 2026 21:22:30 -0500 Subject: Fixing the next three scripts - `Tak0-Per-Window-Switch.sh` now records the listener PID in ``~/.cache/kb_layout_per_window.listener.pid`` - reuses it if still running, preventing multiple background listeners - reports missing Hyprland sockets without exiting the main script. - `WaybarScripts.sh` adds a `launch_files()` helper that checks `$files` before execution; - if unset, it shows a notification instead of running an empty command. - `sddm_wallpaper.sh` validates `~/.config/rofi/wallust/colors-rofi.rasi` before use - extracts colors via a helper, and aborts with a notification if any required colors are missing. On branch development Your branch is up to date with 'origin/development'. Changes to be committed: modified: CHANGELOG.md modified: config/hypr/scripts/Tak0-Per-Window-Switch.sh modified: config/hypr/scripts/WaybarScripts.sh modified: config/hypr/scripts/sddm_wallpaper.sh --- CHANGELOG.md | 3 +++ config/hypr/scripts/Tak0-Per-Window-Switch.sh | 20 ++++++++++++--- config/hypr/scripts/WaybarScripts.sh | 10 +++++++- config/hypr/scripts/sddm_wallpaper.sh | 37 ++++++++++++++++++++++----- 4 files changed, 58 insertions(+), 12 deletions(-) (limited to 'config/hypr/scripts/Tak0-Per-Window-Switch.sh') diff --git a/CHANGELOG.md b/CHANGELOG.md index d9f88343..5089b350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ - `RofiSearch.sh` verifies that `jq` is available, captures the user’s query explicitly, URL-encodes it via `jq` `@uri`, - opens the configured search engine with the encoded query instead of dropping the term. - `Sounds.sh` now tries `pw-play`, then `paplay`, then `aplay`, emitting a clear error if none are installed, so the script no longer calls the non-existent pa-play. + - `Tak0-Per-Window-Switch.sh` now records the listener PID in `~/.cache/kb_layout_per_window.listener.pid` and reuses it if still running, preventing multiple background listeners, and reports missing Hyprland sockets without exiting the main script. + - `WaybarScripts.sh` adds a `launch_files()` helper that checks `$files` before execution; if unset, it shows a notification instead of running an empty command. + - `sddm_wallpaper.sh` validates `~/.config/rofi/wallust/colors-rofi.rasi` before use, extracts colors via a helper, and aborts with a notification if any required colors are missing. - 2026-01-06 - Added Global Theme Changer. diff --git a/config/hypr/scripts/Tak0-Per-Window-Switch.sh b/config/hypr/scripts/Tak0-Per-Window-Switch.sh index 7879fb85..7cec89a6 100755 --- a/config/hypr/scripts/Tak0-Per-Window-Switch.sh +++ b/config/hypr/scripts/Tak0-Per-Window-Switch.sh @@ -17,6 +17,7 @@ MAP_FILE="$HOME/.cache/kb_layout_per_window" CFG_FILE="$HOME/.config/hypr/configs/SystemSettings.conf" ICON="$HOME/.config/swaync/images/ja.png" SCRIPT_NAME="$(basename "$0")" +LISTENER_PIDFILE="$HOME/.cache/kb_layout_per_window.listener.pid" # Ensure map file exists touch "$MAP_FILE" @@ -99,7 +100,7 @@ subscribe() { local SOCKET2="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" [[ -S "$SOCKET2" ]] || { echo "Error: Hyprland socket not found." >&2 - exit 1 + return 1 } socat -u UNIX-CONNECT:"$SOCKET2" - | while read -r line; do @@ -108,9 +109,20 @@ subscribe() { } # Ensure only one listener -if ! pgrep -f "$SCRIPT_NAME.*--listener" >/dev/null; then - subscribe --listener & -fi +start_listener_once() { + if [[ -f "$LISTENER_PIDFILE" ]]; then + local existing_pid + existing_pid=$(cat "$LISTENER_PIDFILE" 2>/dev/null || true) + if [[ -n "$existing_pid" ]] && kill -0 "$existing_pid" 2>/dev/null; then + return + fi + fi + + subscribe & + echo $! >"$LISTENER_PIDFILE" +} + +start_listener_once # CLI case "$1" in diff --git a/config/hypr/scripts/WaybarScripts.sh b/config/hypr/scripts/WaybarScripts.sh index d2205c42..54f7a4b4 100755 --- a/config/hypr/scripts/WaybarScripts.sh +++ b/config/hypr/scripts/WaybarScripts.sh @@ -24,6 +24,14 @@ if [[ -z "$term" ]]; then fi # Execute accordingly based on the passed argument +launch_files() { + if [[ -z "$files" ]]; then + notify-send -u low -i "$HOME/.config/swaync/images/error.png" "Waybar: files" "Set \$files in 01-UserDefaults.conf or install a default file manager." + return 1 + fi + eval "$files &" +} + if [[ "$1" == "--btop" ]]; then $term --title btop sh -c 'btop' elif [[ "$1" == "--nvtop" ]]; then @@ -33,7 +41,7 @@ elif [[ "$1" == "--nmtui" ]]; then elif [[ "$1" == "--term" ]]; then $term & elif [[ "$1" == "--files" ]]; then - $files & + launch_files else echo "Usage: $0 [--btop | --nvtop | --nmtui | --term]" echo "--btop : Open btop in a new term" diff --git a/config/hypr/scripts/sddm_wallpaper.sh b/config/hypr/scripts/sddm_wallpaper.sh index 5ebab44c..b83f800a 100755 --- a/config/hypr/scripts/sddm_wallpaper.sh +++ b/config/hypr/scripts/sddm_wallpaper.sh @@ -21,6 +21,10 @@ sddm_simple="$sddm_themes_dir/simple_sddm_2" # rofi-wallust-sddm colors path rofi_wallust="$HOME/.config/rofi/wallust/colors-rofi.rasi" sddm_theme_conf="$sddm_simple/theme.conf" +if [[ ! -f "$rofi_wallust" ]]; then + notify-send -i "$iDIR/error.png" "SDDM" "Wallust colors file not found ($rofi_wallust). Aborting." + exit 1 +fi # Directory for swaync iDIR="$HOME/.config/swaync/images" @@ -36,13 +40,32 @@ fi # Extract colors from rofi wallust config -color0=$(grep -oP 'color1:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") -color1=$(grep -oP 'color0:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") -color7=$(grep -oP 'color14:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") -color10=$(grep -oP 'color10:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") -color12=$(grep -oP 'color12:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") -color13=$(grep -oP 'color13:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") -foreground=$(grep -oP 'foreground:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") +extract_color() { + local key="$1" + local value + value=$(grep -oP "$key:\s*\K#[A-Fa-f0-9]+" "$rofi_wallust" | head -n1) + echo "$value" +} + +color0=$(extract_color "color1") +color1=$(extract_color "color0") +color7=$(extract_color "color14") +color10=$(extract_color "color10") +color12=$(extract_color "color12") +color13=$(extract_color "color13") +foreground=$(extract_color "foreground") + +missing_colors=() +for var in color0 color1 color7 color10 color12 color13 foreground; do + if [[ -z "${!var}" ]]; then + missing_colors+=("$var") + fi +done + +if [[ ${#missing_colors[@]} -gt 0 ]]; then + notify-send -i "$iDIR/error.png" "SDDM" "Missing color(s): ${missing_colors[*]}. Run Wallust first." + exit 1 +fi #background-color=$(grep -oP 'background:\s*\K#[A-Fa-f0-9]+' "$rofi_wallust") # wallpaper to use -- cgit v1.2.3