diff options
Diffstat (limited to 'config/hypr/UserScripts/WallpaperEffects.sh')
| -rwxr-xr-x | config/hypr/UserScripts/WallpaperEffects.sh | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/config/hypr/UserScripts/WallpaperEffects.sh b/config/hypr/UserScripts/WallpaperEffects.sh index e1c8fe83..297c77fa 100755 --- a/config/hypr/UserScripts/WallpaperEffects.sh +++ b/config/hypr/UserScripts/WallpaperEffects.sh @@ -12,13 +12,10 @@ terminal=kitty wallpaper_current="$HOME/.config/hypr/wallpaper_effects/.wallpaper_current" wallpaper_output="$HOME/.config/hypr/wallpaper_effects/.wallpaper_modified" SCRIPTSDIR="$HOME/.config/hypr/scripts" +# shellcheck source=/dev/null +. "$SCRIPTSDIR/WallpaperCmd.sh" focused_monitor=$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .name') rofi_theme="$HOME/.config/rofi/config-wallpaper-effect.rasi" -if command -v awww >/dev/null 2>&1; then - WWW="awww" -else - WWW="swww" -fi # Directory for swaync iDIR="$HOME/.config/swaync/images" @@ -29,10 +26,10 @@ FPS=60 TYPE="wipe" DURATION=2 BEZIER=".43,1.19,1,.4" -if [[ "$WWW" == "swww" || "$WWW" == "awww" ]]; then - SWWW_PARAMS="--transition-fps $FPS --transition-type $TYPE --transition-duration $DURATION --transition-bezier $BEZIER" +if [[ "$WWW_CMD" == "swww" || "$WWW_CMD" == "awww" ]]; then + SWWW_PARAMS=(--transition-fps "$FPS" --transition-type "$TYPE" --transition-duration "$DURATION" --transition-bezier "$BEZIER") else - SWWW_PARAMS="" + SWWW_PARAMS=() fi # Define ImageMagick effects @@ -59,12 +56,15 @@ declare -A effects=( # Function to apply no effects no-effects() { - $WWW img -o "$focused_monitor" "$wallpaper_current" $SWWW_PARAMS && - wait $! - wallust run "$wallpaper_current" -s && - wait $! + local resize_mode + resize_mode="$(wallpaper_resize_mode "$wallpaper_current" "$focused_monitor")" + "$WWW_CMD" img -o "$focused_monitor" --resize "$resize_mode" "$wallpaper_current" "${SWWW_PARAMS[@]}" || return 1 + if ! "$SCRIPTSDIR/WallustSwww.sh" "$wallpaper_current"; then + notify-send -u critical -i "$iDIR/error.png" "Wallust failed" "Wallpaper theme not refreshed" + return 1 + fi # Refresh rofi, waybar, wallust palettes - sleep 2 + sleep 0.5 "$SCRIPTSDIR/Refresh.sh" notify-send -u low -i "$iDIR/ja.png" "No wallpaper" "effects applied" @@ -90,19 +90,21 @@ main() { # Apply selected effect notify-send -u normal -i "$iDIR/ja.png" "Applying:" "$choice effects" eval "${effects[$choice]}" - + # intial kill process for pid in swaybg mpvpaper; do killall -SIGUSR1 "$pid" done sleep 1 - $WWW img -o "$focused_monitor" "$wallpaper_output" $SWWW_PARAMS & - - sleep 2 - - wallust run "$wallpaper_output" -s & - sleep 1 + local resize_mode + resize_mode="$(wallpaper_resize_mode "$wallpaper_output" "$focused_monitor")" + "$WWW_CMD" img -o "$focused_monitor" --resize "$resize_mode" "$wallpaper_output" "${SWWW_PARAMS[@]}" + sleep 0.5 + if ! "$SCRIPTSDIR/WallustSwww.sh" "$wallpaper_output"; then + notify-send -u critical -i "$iDIR/error.png" "Wallust failed" "Wallpaper theme not refreshed" + return 1 + fi # Refresh rofi, waybar, wallust palettes "${SCRIPTSDIR}/Refresh.sh" notify-send -u low -i "$iDIR/ja.png" "$choice" "effects applied" |
