Fix: Rewrite animation picker to switch Lua presets
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,34 +1,6 @@
|
||||
-- HyprFlux — https://github.com/ahmad9059/HyprFlux
|
||||
-- Ported from UserConfigs/UserAnimations.conf (the active preset)
|
||||
--
|
||||
-- The 14 alternative presets from animations/*.conf were also ported, flat, as
|
||||
-- anim-*.lua (see the plan) — none of them are wired in. They now live in ../presets/.
|
||||
-- To switch styles, replace the body of this file with `require("presets.anim-<preset>")`,
|
||||
-- e.g. require("presets.anim-ml4w-classic").
|
||||
-- Active animation preset.
|
||||
-- The presets live in ../presets/anim-*.lua. Super+Shift+A (scripts/Animations.sh)
|
||||
-- picks one and rewrites the require() line below; edit it by hand to switch too,
|
||||
-- e.g. require("presets.anim-ml4w-classic"). Keep it to this single line.
|
||||
|
||||
hl.config({
|
||||
animations = {
|
||||
enabled = true,
|
||||
},
|
||||
})
|
||||
|
||||
hl.curve("wind", { type = "bezier", points = { { 0.05, 0.9 }, { 0.1, 1.05 } } })
|
||||
hl.curve("winIn", { type = "bezier", points = { { 0.1, 1.1 }, { 0.1, 1.1 } } })
|
||||
hl.curve("winOut", { type = "bezier", points = { { 0.3, -0.3 }, { 0, 1 } } })
|
||||
hl.curve("liner", { type = "bezier", points = { { 1, 1 }, { 1, 1 } } })
|
||||
hl.curve("overshot", { type = "bezier", points = { { 0.05, 0.9 }, { 0.1, 1.05 } } })
|
||||
hl.curve("smoothOut", { type = "bezier", points = { { 0.5, 0 }, { 0.99, 0.99 } } })
|
||||
hl.curve("smoothIn", { type = "bezier", points = { { 0.5, -0.5 }, { 0.68, 1.5 } } })
|
||||
|
||||
hl.animation({ leaf = "windows", enabled = true, speed = 6, bezier = "wind", style = "slide" })
|
||||
hl.animation({ leaf = "windowsIn", enabled = true, speed = 5, bezier = "winIn", style = "slide" })
|
||||
hl.animation({ leaf = "windowsOut", enabled = true, speed = 3, bezier = "smoothOut", style = "slide" })
|
||||
hl.animation({ leaf = "windowsMove", enabled = true, speed = 5, bezier = "wind", style = "slide" })
|
||||
hl.animation({ leaf = "border", enabled = true, speed = 1, bezier = "liner" })
|
||||
hl.animation({ leaf = "borderangle", enabled = true, speed = 100, bezier = "liner", style = "loop" }) -- used by rainbow borders and rotating colors; speed clamped from 180 -> Lua hl.animation caps speed at 100
|
||||
hl.animation({ leaf = "fade", enabled = true, speed = 3, bezier = "smoothOut" })
|
||||
hl.animation({ leaf = "workspaces", enabled = true, speed = 5, bezier = "overshot" })
|
||||
|
||||
-- animations for -git or version >0.42.0
|
||||
hl.animation({ leaf = "workspacesIn", enabled = true, speed = 5, bezier = "winIn", style = "slide" })
|
||||
hl.animation({ leaf = "workspacesOut", enabled = true, speed = 5, bezier = "winOut", style = "slide" })
|
||||
require("presets.anim-hyprflux")
|
||||
|
||||
31
dotfiles/.config/hypr/presets/anim-hyprflux.lua
Normal file
31
dotfiles/.config/hypr/presets/anim-hyprflux.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
-- HyprFlux — https://github.com/ahmad9059/HyprFlux
|
||||
-- name "HyprFlux (default)"
|
||||
-- The animation set that shipped as appearance/animations.lua (ported from
|
||||
-- UserConfigs/UserAnimations.conf). Selected by default; Super+Shift+A switches.
|
||||
|
||||
hl.config({
|
||||
animations = {
|
||||
enabled = true,
|
||||
},
|
||||
})
|
||||
|
||||
hl.curve("wind", { type = "bezier", points = { { 0.05, 0.9 }, { 0.1, 1.05 } } })
|
||||
hl.curve("winIn", { type = "bezier", points = { { 0.1, 1.1 }, { 0.1, 1.1 } } })
|
||||
hl.curve("winOut", { type = "bezier", points = { { 0.3, -0.3 }, { 0, 1 } } })
|
||||
hl.curve("liner", { type = "bezier", points = { { 1, 1 }, { 1, 1 } } })
|
||||
hl.curve("overshot", { type = "bezier", points = { { 0.05, 0.9 }, { 0.1, 1.05 } } })
|
||||
hl.curve("smoothOut", { type = "bezier", points = { { 0.5, 0 }, { 0.99, 0.99 } } })
|
||||
hl.curve("smoothIn", { type = "bezier", points = { { 0.5, -0.5 }, { 0.68, 1.5 } } })
|
||||
|
||||
hl.animation({ leaf = "windows", enabled = true, speed = 6, bezier = "wind", style = "slide" })
|
||||
hl.animation({ leaf = "windowsIn", enabled = true, speed = 5, bezier = "winIn", style = "slide" })
|
||||
hl.animation({ leaf = "windowsOut", enabled = true, speed = 3, bezier = "smoothOut", style = "slide" })
|
||||
hl.animation({ leaf = "windowsMove", enabled = true, speed = 5, bezier = "wind", style = "slide" })
|
||||
hl.animation({ leaf = "border", enabled = true, speed = 1, bezier = "liner" })
|
||||
hl.animation({ leaf = "borderangle", enabled = true, speed = 100, bezier = "liner", style = "loop" }) -- used by rainbow borders and rotating colors; speed clamped from 180 -> Lua hl.animation caps speed at 100
|
||||
hl.animation({ leaf = "fade", enabled = true, speed = 3, bezier = "smoothOut" })
|
||||
hl.animation({ leaf = "workspaces", enabled = true, speed = 5, bezier = "overshot" })
|
||||
|
||||
-- animations for -git or version >0.42.0
|
||||
hl.animation({ leaf = "workspacesIn", enabled = true, speed = 5, bezier = "winIn", style = "slide" })
|
||||
hl.animation({ leaf = "workspacesOut", enabled = true, speed = 5, bezier = "winOut", style = "slide" })
|
||||
@@ -1,31 +1,38 @@
|
||||
#!/bin/bash
|
||||
# HyprFlux — https://github.com/ahmad9059/HyprFlux
|
||||
# For applying Animations from different users
|
||||
# Animation preset picker (Super+Shift+A).
|
||||
# Lists ~/.config/hypr/presets/anim-*.lua by their original HyprFlux preset name
|
||||
# (the "Ported from animations/<name>.conf" line, else `-- name "..."`), then
|
||||
# points appearance/animations.lua's require() at the chosen one and reloads.
|
||||
|
||||
iDIR="$HOME/.config/swaync/images"
|
||||
presets_dir="$HOME/.config/hypr/presets"
|
||||
active_file="$HOME/.config/hypr/appearance/animations.lua"
|
||||
rofi_theme="$HOME/.config/rofi/launchers/type-4/style-4.rasi"
|
||||
|
||||
# Check if rofi is already running
|
||||
if pidof rofi >/dev/null; then
|
||||
pkill rofi
|
||||
fi
|
||||
|
||||
# Variables
|
||||
iDIR="$HOME/.config/swaync/images"
|
||||
SCRIPTSDIR="$HOME/.config/hypr/scripts"
|
||||
animations_dir="$HOME/.config/hypr/animations"
|
||||
UserConfigs="$HOME/.config/hypr/UserConfigs"
|
||||
rofi_theme="$HOME/.config/rofi/config-Animations.rasi"
|
||||
msg='❗NOTE:❗ This will copy animations into UserAnimations.conf'
|
||||
# list of animation files, sorted alphabetically with numbers first
|
||||
animations_list=$(find -L "$animations_dir" -maxdepth 1 -type f | sed 's/.*\///' | sed 's/\.conf$//' | sort -V)
|
||||
# "Display name<TAB>module" per preset, sorted by name
|
||||
list=$(for f in "$presets_dir"/anim-*.lua; do
|
||||
module=$(basename "$f" .lua)
|
||||
name=$(sed -n 's/^-- Ported from animations\/\(.*\)\.conf.*/\1/p' "$f" | head -n1)
|
||||
[[ -z "$name" ]] && name=$(sed -n 's/^-- name "\(.*\)"$/\1/p' "$f" | head -n1)
|
||||
printf '%s\t%s\n' "${name:-$module}" "$module"
|
||||
done | sort -f)
|
||||
|
||||
# Rofi Menu
|
||||
chosen_file=$(echo "$animations_list" | rofi -i -dmenu -config $rofi_theme -mesg "$msg")
|
||||
current=$(sed -n 's/^require("presets\.\(.*\)")$/\1/p' "$active_file")
|
||||
current_name=$(awk -F'\t' -v m="$current" '$2 == m { print $1 }' <<<"$list")
|
||||
|
||||
# Check if a file was selected
|
||||
if [[ -n "$chosen_file" ]]; then
|
||||
full_path="$animations_dir/$chosen_file.conf"
|
||||
cp "$full_path" "$UserConfigs/UserAnimations.conf"
|
||||
notify-send -u low -i "$iDIR/ja.png" "$chosen_file" "Hyprland Animation Loaded"
|
||||
fi
|
||||
chosen=$(cut -f1 <<<"$list" | rofi -i -dmenu -p "Animations" \
|
||||
-theme "$rofi_theme" \
|
||||
-theme-str 'mainbox { children: [ "inputbar", "message", "listview" ]; }' \
|
||||
-mesg "Current: ${current_name:-$current}")
|
||||
[[ -z "$chosen" ]] && exit 0
|
||||
|
||||
sleep 1
|
||||
"$SCRIPTSDIR/RefreshNoWaybar.sh"
|
||||
module=$(awk -F'\t' -v n="$chosen" '$1 == n { print $2; exit }' <<<"$list")
|
||||
[[ -z "$module" ]] && exit 1
|
||||
|
||||
sed -i "s/^require(\"presets\.[^\"]*\")$/require(\"presets.$module\")/" "$active_file"
|
||||
hyprctl reload >/dev/null
|
||||
notify-send -u low -i "$iDIR/note.png" "$chosen" "Hyprland animation loaded"
|
||||
|
||||
Reference in New Issue
Block a user