From c65f9fe0412dafdadee17ee3dc7c42285dcc3753 Mon Sep 17 00:00:00 2001 From: Don Williams Date: Thu, 8 Jan 2026 21:31:11 -0500 Subject: Fixing more scripts for Hyprland-Dots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `WallustSwww.sh` now reads the focused monitor’s cache file (or parses swww query per-monitor) to pick the correct wallpaper path - Eliminating the previous “last line wins” bug on multi-monitor setups. - `PortalHyprland.sh` suppresses harmless killall errors and launches only the first available portal binary in each category (hyprland + general) - Avoiding duplicate processes when both `/usr/lib` and `/usr/libexec` variants exist. - `KillActiveProcess.sh` checks that Hyprland returned a numeric PID before calling kill - Notifies the user when no active window is available instead of throwing kill usage errors. On branch development Your branch is up to date with 'origin/development'. Changes to be committed: modified: CHANGELOG.md modified: config/hypr/scripts/KillActiveProcess.sh modified: config/hypr/scripts/PortalHyprland.sh modified: config/hypr/scripts/WallustSwww.sh --- CHANGELOG.md | 6 +++++ config/hypr/scripts/KillActiveProcess.sh | 7 +++++- config/hypr/scripts/PortalHyprland.sh | 40 +++++++++++++++++++++++++------- config/hypr/scripts/WallustSwww.sh | 29 ++++++++++++++++++++--- 4 files changed, 70 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5089b350..319d1fd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,12 @@ - `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. + - `WallustSwww.sh` now reads the focused monitor’s cache file (or parses swww query per-monitor) to pick the correct wallpaper path + - Eliminating the previous “last line wins” bug on multi-monitor setups. + - `PortalHyprland.sh` suppresses harmless killall errors and launches only the first available portal binary in each category (hyprland + general) + - Avoiding duplicate processes when both `/usr/lib` and `/usr/libexec` variants exist. + - `KillActiveProcess.sh` checks that Hyprland returned a numeric PID before calling kill + - Notifies the user when no active window is available instead of throwing kill usage errors. - 2026-01-06 - Added Global Theme Changer. diff --git a/config/hypr/scripts/KillActiveProcess.sh b/config/hypr/scripts/KillActiveProcess.sh index 2bc108f2..d9d26bb3 100755 --- a/config/hypr/scripts/KillActiveProcess.sh +++ b/config/hypr/scripts/KillActiveProcess.sh @@ -7,5 +7,10 @@ # Get id of an active window active_pid=$(hyprctl activewindow | grep -o 'pid: [0-9]*' | cut -d' ' -f2) +if [[ -z "$active_pid" || ! "$active_pid" =~ ^[0-9]+$ ]]; then + notify-send -u low -i "$HOME/.config/swaync/images/error.png" "Kill Active Window" "No active window PID found." + exit 1 +fi + # Close active window -kill $active_pid \ No newline at end of file +kill "$active_pid" diff --git a/config/hypr/scripts/PortalHyprland.sh b/config/hypr/scripts/PortalHyprland.sh index 21cb7db4..653e9b58 100755 --- a/config/hypr/scripts/PortalHyprland.sh +++ b/config/hypr/scripts/PortalHyprland.sh @@ -2,15 +2,39 @@ # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## # For manually starting xdg-desktop-portal-hyprland +set -euo pipefail + +kill_quietly() { + killall -q "$1" 2>/dev/null || true +} + +start_portal_binary() { + local description="$1" + shift + for candidate in "$@"; do + if [[ -x "$candidate" ]]; then + "$candidate" & + return 0 + fi + done + echo "Warning: no $description binary found (checked: $*)" >&2 + return 1 +} + sleep 1 -killall xdg-desktop-portal-hyprland -killall xdg-desktop-portal-wlr -killall xdg-desktop-portal-gnome -killall xdg-desktop-portal +kill_quietly xdg-desktop-portal-hyprland +kill_quietly xdg-desktop-portal-wlr +kill_quietly xdg-desktop-portal-gnome +kill_quietly xdg-desktop-portal sleep 1 -/usr/lib/xdg-desktop-portal-hyprland & -/usr/libexec/xdg-desktop-portal-hyprland & + +start_portal_binary "xdg-desktop-portal-hyprland" \ + /usr/lib/xdg-desktop-portal-hyprland \ + /usr/libexec/xdg-desktop-portal-hyprland + sleep 2 -/usr/lib/xdg-desktop-portal & -/usr/libexec/xdg-desktop-portal & + +start_portal_binary "xdg-desktop-portal" \ + /usr/lib/xdg-desktop-portal \ + /usr/libexec/xdg-desktop-portal diff --git a/config/hypr/scripts/WallustSwww.sh b/config/hypr/scripts/WallustSwww.sh index d1e53400..50c85630 100755 --- a/config/hypr/scripts/WallustSwww.sh +++ b/config/hypr/scripts/WallustSwww.sh @@ -10,6 +10,27 @@ passed_path="${1:-}" cache_dir="$HOME/.cache/swww/" rofi_link="$HOME/.config/rofi/.current_wallpaper" wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" +read_cached_wallpaper() { + local cache_file="$1" + if [[ -f "$cache_file" ]]; then + awk 'NF && $0 !~ /^filter/ {print; exit}' "$cache_file" + fi +} + +read_wallpaper_from_query() { + local monitor="$1" + swww query | awk -v mon="$monitor" ' + /^Monitor/ { + cur=$2 + gsub(":", "", cur) + } + /image:/ && cur==mon { + sub(/^.*image: /,"") + print + exit + } + ' +} # Helper: get focused monitor name (prefer JSON) get_focused_monitor() { @@ -39,9 +60,11 @@ else if [[ -f "$cache_file" ]]; then # The first non-filter line is the original wallpaper path - # wallpaper_path="$(grep -v 'Lanczos3' "$cache_file" | head -n 1)" - # wallpaper_path=$(swww query | grep $current_monitor | awk '{print $9}') - wallpaper_path=$(swww query | sed 's/.*image: //') + wallpaper_path="$(read_cached_wallpaper "$cache_file")" + fi + + if [[ -z "$wallpaper_path" ]]; then + wallpaper_path="$(read_wallpaper_from_query "$current_monitor")" fi fi -- cgit v1.2.3