aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/Animations.sh
blob: ae93429bf073dd02ea32c0de2984543e14f1748a (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
#!/usr/bin/env bash
# ==================================================
#  KoolDots (2026)
#  Project URL: https://github.com/LinuxBeginnings
#  License: GNU GPLv3
#  SPDX-License-Identifier: GPL-3.0-or-later
# ==================================================
# For applying Animations from different users

# Check if rofi is already running
if pidof rofi > /dev/null; then
  pkill rofi
fi

# Variables
iDIR="${XDG_CONFIG_HOME:-$HOME/.config}/swaync/images"
SCRIPTSDIR="${XDG_CONFIG_HOME:-$HOME/.config}/hypr/scripts"
animations_dir="${XDG_CONFIG_HOME:-$HOME/.config}/hypr/animations"
UserConfigs="${XDG_CONFIG_HOME:-$HOME/.config}/hypr/UserConfigs"
rofi_theme="${XDG_CONFIG_HOME:-$HOME/.config}/rofi/config-Animations.rasi"
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"

# Detect active Hyprland config mode (Lua entrypoint vs legacy .conf includes)
if [[ -f "$lua_entry" || -f "$legacy_lua_entry" ]]; then
  hypr_config_mode="lua"
  animation_ext="lua"
  target_animation_file="$UserConfigs/user_animations.lua"
  msg='❗NOTE:❗ This will copy animations into user_animations.lua'
else
  hypr_config_mode="conf"
  animation_ext="conf"
  target_animation_file="$UserConfigs/UserAnimations.conf"
  msg='❗NOTE:❗ This will copy animations into UserAnimations.conf'
fi

# list of animation files, sorted alphabetically with numbers first
animations_list=$(find -L "$animations_dir" -maxdepth 1 -type f -name "*.${animation_ext}" | sed 's/.*\///' | sed "s/\.${animation_ext}$//" | sort -V)

if [[ -z "$animations_list" ]]; then
    notify-send -u normal -i "$iDIR/ja.png" "No animation presets found" "Expected *.${animation_ext} in $animations_dir"
    exit 0
fi

# Rofi Menu
chosen_file=$(echo "$animations_list" | rofi -i -dmenu -config "$rofi_theme" -mesg "$msg")

# Check if a file was selected
if [[ -n "$chosen_file" ]]; then
    full_path="$animations_dir/$chosen_file.$animation_ext"
    cp "$full_path" "$target_animation_file"
    notify-send -u low -i "$iDIR/ja.png" "$chosen_file" "Hyprland Animation Loaded"
fi

sleep 1
"$SCRIPTSDIR/RefreshNoWaybar.sh"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage