aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr
diff options
context:
space:
mode:
Diffstat (limited to 'config/hypr')
-rwxr-xr-xconfig/hypr/scripts/ChangeBlur.sh191
1 files changed, 153 insertions, 38 deletions
diff --git a/config/hypr/scripts/ChangeBlur.sh b/config/hypr/scripts/ChangeBlur.sh
index 7d3fb42d..66269a2c 100755
--- a/config/hypr/scripts/ChangeBlur.sh
+++ b/config/hypr/scripts/ChangeBlur.sh
@@ -5,9 +5,15 @@
# License: GNU GPLv3
# SPDX-License-Identifier: GPL-3.0-or-later
# ==================================================
-# Script for changing blurs on the fly
+# Script for changing blur levels on the fly with desktop notifications.
+# Supports cycling preset levels (Off -> Low -> Medium -> High -> Ultra),
+# stepping up/down (--inc / --dec), or selecting explicit levels.
+# Uses flock to prevent double-execution from dual-config (.conf + .lua) loading.
+
+set -uo pipefail
notif="${XDG_CONFIG_HOME:-$HOME/.config}/swaync/images"
+icons_dir="${XDG_CONFIG_HOME:-$HOME/.config}/swaync/icons"
config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
hypr_dir="$config_home/hypr"
@@ -22,6 +28,21 @@ fi
LOCK="/tmp/.hypr_change_blur_${HYPRLAND_INSTANCE_SIGNATURE:-default}.lock"
+# Pick appropriate icons
+if [[ -f "$icons_dir/palette.png" ]]; then
+ ICON_ON="$icons_dir/palette.png"
+elif [[ -f "$notif/ja.png" ]]; then
+ ICON_ON="$notif/ja.png"
+else
+ ICON_ON="$notif/note.png"
+fi
+
+if [[ -f "$notif/note.png" ]]; then
+ ICON_OFF="$notif/note.png"
+else
+ ICON_OFF="$ICON_ON"
+fi
+
(
flock -n 200 || exit 0
@@ -31,47 +52,141 @@ LOCK="/tmp/.hypr_change_blur_${HYPRLAND_INSTANCE_SIGNATURE:-default}.lock"
BLUR_ENABLED=$(hyprctl getoption decoration:blur:enabled 2>/dev/null | awk 'NR==1{print $2}')
fi
- STATE=$(hyprctl -j getoption decoration:blur:passes 2>/dev/null | jq -r ".int // empty")
- if [[ -z "$STATE" || "$STATE" == "null" ]]; then
- STATE=$(hyprctl getoption decoration:blur:passes 2>/dev/null | awk 'NR==1{print $2}')
+ PASSES=$(hyprctl -j getoption decoration:blur:passes 2>/dev/null | jq -r ".int // empty")
+ if [[ -z "$PASSES" || "$PASSES" == "null" ]]; then
+ PASSES=$(hyprctl getoption decoration:blur:passes 2>/dev/null | awk 'NR==1{print $2}')
fi
- # If blur was disabled or 0 passes, enable Normal Blur
- if [[ "$BLUR_ENABLED" == "false" || "$BLUR_ENABLED" == "0" || "${STATE}" == "0" ]]; then
- if [[ "$hypr_config_mode" == "lua" ]]; then
- hyprctl -r eval "hl.config({ decoration = { blur = { enabled = true, size = 6, passes = 3, ignore_opacity = true, xray = false, new_optimizations = true } } })" >/dev/null 2>&1 || true
- else
- hyprctl keyword decoration:blur:enabled 1
- hyprctl keyword decoration:blur:size 6
- hyprctl keyword decoration:blur:passes 3
- hyprctl keyword decoration:blur:ignore_opacity 1
- hyprctl keyword decoration:blur:xray 0
- hyprctl keyword decoration:blur:new_optimizations 1
- fi
- notify-send -e -u low -i "$notif/ja.png" " Normal Blur"
- elif [ "${STATE:-2}" -ge 2 ]; then
- if [[ "$hypr_config_mode" == "lua" ]]; then
- hyprctl -r eval "hl.config({ decoration = { blur = { enabled = true, size = 2, passes = 1, ignore_opacity = true, xray = false, new_optimizations = true } } })" >/dev/null 2>&1 || true
- else
- hyprctl keyword decoration:blur:enabled 1
- hyprctl keyword decoration:blur:size 2
- hyprctl keyword decoration:blur:passes 1
- hyprctl keyword decoration:blur:ignore_opacity 1
- hyprctl keyword decoration:blur:xray 0
- hyprctl keyword decoration:blur:new_optimizations 1
- fi
- notify-send -e -u low -i "$notif/note.png" " Less Blur"
+ # Determine current level (0: Off, 1: Low, 2: Medium, 3: High, 4: Ultra)
+ if [[ "$BLUR_ENABLED" == "false" || "$BLUR_ENABLED" == "0" || "${PASSES:-0}" -le 0 ]]; then
+ CURRENT_LEVEL=0
+ elif [ "${PASSES}" -eq 1 ]; then
+ CURRENT_LEVEL=1
+ elif [ "${PASSES}" -eq 2 ]; then
+ CURRENT_LEVEL=2
+ elif [ "${PASSES}" -eq 3 ]; then
+ CURRENT_LEVEL=3
else
- if [[ "$hypr_config_mode" == "lua" ]]; then
- hyprctl -r eval "hl.config({ decoration = { blur = { enabled = true, size = 6, passes = 3, ignore_opacity = true, xray = false, new_optimizations = true } } })" >/dev/null 2>&1 || true
+ CURRENT_LEVEL=4
+ fi
+
+ ACTION="${1:---toggle}"
+
+ case "$ACTION" in
+ --inc|+|-inc|inc|up|--up)
+ TARGET_LEVEL=$((CURRENT_LEVEL + 1))
+ (( TARGET_LEVEL > 4 )) && TARGET_LEVEL=4
+ ;;
+ --dec|-|-dec|dec|down|--down)
+ TARGET_LEVEL=$((CURRENT_LEVEL - 1))
+ (( TARGET_LEVEL < 0 )) && TARGET_LEVEL=0
+ ;;
+ --off|off|0)
+ TARGET_LEVEL=0
+ ;;
+ --low|low|1)
+ TARGET_LEVEL=1
+ ;;
+ --med|--medium|--normal|medium|normal|2)
+ TARGET_LEVEL=2
+ ;;
+ --high|high|3)
+ TARGET_LEVEL=3
+ ;;
+ --ultra|--max|ultra|max|4)
+ TARGET_LEVEL=4
+ ;;
+ --toggle|toggle|"")
+ # Cycle: Off (0) -> Low (1) -> Medium (2) -> High (3) -> Ultra (4) -> Off (0)
+ case "$CURRENT_LEVEL" in
+ 0) TARGET_LEVEL=1 ;;
+ 1) TARGET_LEVEL=2 ;;
+ 2) TARGET_LEVEL=3 ;;
+ 3) TARGET_LEVEL=4 ;;
+ *) TARGET_LEVEL=0 ;;
+ esac
+ ;;
+ *)
+ # Parse numeric arg directly
+ if [[ "$ACTION" =~ ^[0-4]$ ]]; then
+ TARGET_LEVEL="$ACTION"
else
- hyprctl keyword decoration:blur:enabled 1
- hyprctl keyword decoration:blur:size 6
- hyprctl keyword decoration:blur:passes 3
- hyprctl keyword decoration:blur:ignore_opacity 1
- hyprctl keyword decoration:blur:xray 0
- hyprctl keyword decoration:blur:new_optimizations 1
+ TARGET_LEVEL=$(( (CURRENT_LEVEL + 1) % 5 ))
fi
- notify-send -e -u low -i "$notif/ja.png" " Normal Blur"
+ ;;
+ esac
+
+ # Map target level to Hyprland blur properties
+ case "$TARGET_LEVEL" in
+ 0)
+ SET_ENABLED="false"
+ SET_SIZE=0
+ SET_PASSES=0
+ LEVEL_NAME="Disabled"
+ PERCENT=0
+ ICON="$ICON_OFF"
+ DETAIL="Blur Off"
+ ;;
+ 1)
+ SET_ENABLED="true"
+ SET_SIZE=3
+ SET_PASSES=1
+ LEVEL_NAME="Low"
+ PERCENT=25
+ ICON="$ICON_ON"
+ DETAIL="Size: 3 | Passes: 1"
+ ;;
+ 2)
+ SET_ENABLED="true"
+ SET_SIZE=6
+ SET_PASSES=2
+ LEVEL_NAME="Medium"
+ PERCENT=50
+ ICON="$ICON_ON"
+ DETAIL="Size: 6 | Passes: 2"
+ ;;
+ 3)
+ SET_ENABLED="true"
+ SET_SIZE=8
+ SET_PASSES=3
+ LEVEL_NAME="High"
+ PERCENT=75
+ ICON="$ICON_ON"
+ DETAIL="Size: 8 | Passes: 3"
+ ;;
+ 4|*)
+ SET_ENABLED="true"
+ SET_SIZE=10
+ SET_PASSES=4
+ LEVEL_NAME="Ultra"
+ PERCENT=100
+ ICON="$ICON_ON"
+ DETAIL="Size: 10 | Passes: 4"
+ ;;
+ esac
+
+ if [[ "$hypr_config_mode" == "lua" ]]; then
+ hyprctl -r eval "hl.config({ decoration = { blur = { enabled = ${SET_ENABLED}, size = ${SET_SIZE}, passes = ${SET_PASSES}, ignore_opacity = true, xray = false, new_optimizations = true } } })" >/dev/null 2>&1 || true
+ else
+ if [[ "$SET_ENABLED" == "true" ]]; then
+ hyprctl keyword decoration:blur:enabled 1
+ else
+ hyprctl keyword decoration:blur:enabled 0
+ fi
+ hyprctl keyword decoration:blur:size "$SET_SIZE"
+ hyprctl keyword decoration:blur:passes "$SET_PASSES"
+ hyprctl keyword decoration:blur:ignore_opacity 1
+ hyprctl keyword decoration:blur:xray 0
+ hyprctl keyword decoration:blur:new_optimizations 1
+ fi
+
+ # Send notification
+ if command -v notify-send >/dev/null 2>&1 && [[ -n "${WAYLAND_DISPLAY:-}${DISPLAY:-}" ]]; then
+ notify-send -e \
+ -h string:x-canonical-private-synchronous:blur_notif \
+ -h int:value:"$PERCENT" \
+ -u low \
+ -i "$ICON" \
+ " Blur: ${LEVEL_NAME}" " ${DETAIL}" 2>/dev/null || true
fi
) 200>"$LOCK"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage