diff options
| author | brockar <martinnguzman.mg@gmail.com> | 2026-01-05 18:16:38 -0300 |
|---|---|---|
| committer | brockar <martinnguzman.mg@gmail.com> | 2026-01-05 18:16:38 -0300 |
| commit | 9a6295cd88fde3e662fd039c7fdc3bf238536f90 (patch) | |
| tree | 66a7dcb7106e0c26dd19ad5958cbbc1b605872e0 | |
| parent | 304552fdc44350f9eb34e50a26d25ea1ff780b79 (diff) | |
scripts: update_WindowRules.sh for hyprland 0.53
| -rwxr-xr-x | config/hypr/scripts/update_WindowRules.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/config/hypr/scripts/update_WindowRules.sh b/config/hypr/scripts/update_WindowRules.sh new file mode 100755 index 00000000..8b4262ba --- /dev/null +++ b/config/hypr/scripts/update_WindowRules.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# 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 + |
