aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/ChangeBlur.sh
blob: 7d3fb42d16c189c7715c9e2945b323d1264d659a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
# ==================================================
#  KoolDots (2026)
#  Project URL: https://github.com/LinuxBeginnings
#  License: GNU GPLv3
#  SPDX-License-Identifier: GPL-3.0-or-later
# ==================================================
# Script for changing blurs on the fly

notif="${XDG_CONFIG_HOME:-$HOME/.config}/swaync/images"

config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
hypr_dir="$config_home/hypr"
lua_entry="$hypr_dir/hyprland.lua"
legacy_lua_entry="$config_home/hyprland.lua"

if [[ -f "$lua_entry" || -f "$legacy_lua_entry" ]]; then
    hypr_config_mode="lua"
else
    hypr_config_mode="conf"
fi

LOCK="/tmp/.hypr_change_blur_${HYPRLAND_INSTANCE_SIGNATURE:-default}.lock"

(
  flock -n 200 || exit 0

  # Check if blur is currently enabled
  BLUR_ENABLED=$(hyprctl -j getoption decoration:blur:enabled 2>/dev/null | jq -r ".bool // empty")
  if [[ -z "$BLUR_ENABLED" || "$BLUR_ENABLED" == "null" ]]; then
      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}')
  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"
  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
      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"
  fi
) 200>"$LOCK"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage