aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/Tak0-Per-Window-Switch.sh
diff options
context:
space:
mode:
authorDon Williams <don.e.williams@gmail.com>2026-01-08 21:22:30 -0500
committerDon Williams <don.e.williams@gmail.com>2026-01-08 21:22:30 -0500
commit3a423138021325a6d97ab0538625305795a6b1c1 (patch)
treefada90c1aceaa89c96639ded30ae802a8dd03c4c /config/hypr/scripts/Tak0-Per-Window-Switch.sh
parent320d2a64813a537f45a986eb4a85fb7b82ed7316 (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
Diffstat (limited to 'config/hypr/scripts/Tak0-Per-Window-Switch.sh')
-rwxr-xr-xconfig/hypr/scripts/Tak0-Per-Window-Switch.sh20
1 files changed, 16 insertions, 4 deletions
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
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage