diff options
| author | Don Williams <don.e.williams@gmail.com> | 2026-01-08 21:22:30 -0500 |
|---|---|---|
| committer | Don Williams <don.e.williams@gmail.com> | 2026-01-08 21:22:30 -0500 |
| commit | 3a423138021325a6d97ab0538625305795a6b1c1 (patch) | |
| tree | fada90c1aceaa89c96639ded30ae802a8dd03c4c | |
| parent | 320d2a64813a537f45a986eb4a85fb7b82ed7316 (diff) | |
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
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rwxr-xr-x | config/hypr/scripts/Tak0-Per-Window-Switch.sh | 20 | ||||
| -rwxr-xr-x | config/hypr/scripts/WaybarScripts.sh | 10 | ||||
| -rwxr-xr-x | config/hypr/scripts/sddm_wallpaper.sh | 37 |
4 files changed, 58 insertions, 12 deletions
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 |
