aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/update_WindowRules.sh
blob: c8d236c4108eb40efbe03e5937ae9467d9a1959a (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
#!/usr/bin/env bash
# ==================================================
#  KoolDots (2026)
#  Project URL: https://github.com/LinuxBeginnings
#  License: GNU GPLv3
#  SPDX-License-Identifier: GPL-3.0-or-later
# ==================================================
# Script to update WindowRules config if Hyprland version is >= 0.53

CONFIGS_DIR="$HOME/.config/hypr/configs"
TARGET_FILE="$CONFIGS_DIR/WindowRules.conf"
V3_FILE="$CONFIGS_DIR/WindowRules-config-v3.conf"

if [[ ! -f "$V3_FILE" ]]; then
  echo "Error: Source configuration file not found: $V3_FILE"
  exit 1
fi

get_hyprland_version() {
  local ver="0.0.0"
  local raw_ver=""

  if command -v hyprctl &>/dev/null; then
    raw_ver=$(hyprctl version 2>/dev/null | grep "Tag:" | cut -d 'v' -f2)
  fi

  if [ -z "$raw_ver" ] && command -v Hyprland &>/dev/null; then
    raw_ver=$(Hyprland --version 2>/dev/null | grep "Tag:" | cut -d 'v' -f2 | awk '{print $1}')
  fi

  if [ -n "$raw_ver" ]; then
    ver=$(echo "$raw_ver" | grep -oE '^[0-9]+\.[0-9]+(\.[0-9]+)?')
  fi

  if [ -z "$ver" ]; then
    echo "0.0.0"
  else
    echo "$ver"
  fi
}

VERSION=$(get_hyprland_version)
REQUIRED_VER="0.53"

# Check if version >= REQUIRED_VER
SMALLEST=$(printf '%s\n' "$REQUIRED_VER" "$VERSION" | sort -V | head -n1)

if [ "$SMALLEST" = "$REQUIRED_VER" ]; then
  echo "Version $VERSION >= $REQUIRED_VER. Updating WindowRules config..."
  # Backup existing config if it exists
  if [ -f "$TARGET_FILE" ]; then
    echo "Backing up existing WindowRules.conf to WindowRules.conf.bak"
    mv "$TARGET_FILE" "$TARGET_FILE.bak"
  fi
  cp "$V3_FILE" "$TARGET_FILE"

  if command -v hyprctl &>/dev/null; then
    if hyprctl instances &>/dev/null; then
      echo "Reloading Hyprland..."
      hyprctl reload
    fi
  fi
else
  echo "Version $VERSION < $REQUIRED_VER. No update needed."
fi

send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage