From 40106ac54138174586b71a01454dec05b10d38a2 Mon Sep 17 00:00:00 2001 From: Uyanide Date: Wed, 8 Oct 2025 00:24:21 +0200 Subject: [PATCH] niri: automatically blur background --- .scripts/change-wallpaper | 2 +- .scripts/niri-autoblur | 23 +++++++++++++++++++++++ niri/config.kdl.template | 3 ++- waybar-niri/config.jsonc | 4 ++-- 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100755 .scripts/niri-autoblur diff --git a/.scripts/change-wallpaper b/.scripts/change-wallpaper index 8066c66..18d840e 100755 --- a/.scripts/change-wallpaper +++ b/.scripts/change-wallpaper @@ -67,7 +67,7 @@ elif [ "$XDG_CURRENT_DESKTOP" = "niri" ]; then notify-send "Blurred Wallpaper set" "Selected wallpaper has been successfully applied for overview" ) & - nohup swww img "$image_copied" --transition-type fade --transition-duration 2 > /dev/null 2> /dev/null & + swww img "$image_copied" --transition-type fade --transition-duration 2 > /dev/null 2> /dev/null notify-send "Wallpaper Changed" "$image" else diff --git a/.scripts/niri-autoblur b/.scripts/niri-autoblur new file mode 100755 index 0000000..f9b6ad3 --- /dev/null +++ b/.scripts/niri-autoblur @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +normal=$(find ~/.config/wallpaper-chooser/current -type f | head -n 1) +blurred=$(find ~/.local/share/swaybg -type f | head -n 1) + +[ -n "$normal" ] || exit 1 +[ -n "$blurred" ] || exit 1 + +while true; do + last=$target + + mapfile -t focused_lines < <(niri msg focused-window 2>/dev/null) + + if [ "${#focused_lines[@]}" -gt 1 ]; then + target="$blurred" + else + target="$normal" + fi + + [ "$target" = "$last" ] || swww img "$target" --transition-type fade --transition-duration 0.5 > /dev/null 2> /dev/null + + sleep 0.5 +done diff --git a/niri/config.kdl.template b/niri/config.kdl.template index 98b7068..807ce44 100644 --- a/niri/config.kdl.template +++ b/niri/config.kdl.template @@ -123,7 +123,8 @@ spawn-at-startup "waybar" // Wallpaper spawn-sh-at-startup "swaybg -i $(find $HOME/.local/share/swaybg -type f) -m fill" -spawn-sh-at-startup "swww-daemon" +spawn-at-startup "swww-daemon" +spawn-at-startup "niri-autoblur" // Not necessary maybe ... spawn-at-startup "fcitx5" diff --git a/waybar-niri/config.jsonc b/waybar-niri/config.jsonc index 47914cb..a3a2376 100644 --- a/waybar-niri/config.jsonc +++ b/waybar-niri/config.jsonc @@ -75,7 +75,8 @@ "today-format": "{}", "on-click": "niri msg action center-column", "on-scroll-up": "niri msg action set-column-width +10%", - "on-scroll-down": "niri msg action set-column-width -10%" + "on-scroll-down": "niri msg action set-column-width -10%", + "on-click-middle": "niri msg action close-window" }, // System monitors @@ -197,7 +198,6 @@ "format": "", "separate-outputs": true, "icon": true, - "on-click-middle": "niri msg action close-window", "icon-size": 14 }, "custom/mediaplayer": {