gardesk/garbg / 8d66b98

Browse files

auto-animate GIF/WebP/APNG URLs without requiring --animate flag

Authored by espadonne
SHA
8d66b9854aeca233b914f8b4ddfc63a2bf704ada
Parents
9c44705
Tree
5b4508c

1 changed file

StatusFile+-
M garbg/src/daemon/state.rs 8 13
garbg/src/daemon/state.rsmodified
@@ -625,18 +625,18 @@ impl Daemon {
625625
                 // Stop any existing animation first
626626
                 self.animation = None;
627627
 
628
-                // Check if we should animate (GIF, WebP, or APNG with animate flag)
628
+                // Detect animated formats from URL/path
629629
                 let source_lower = source.to_lowercase();
630
-                let is_animatable = source_lower.ends_with(".gif")
630
+
631
+                // Formats that are almost always animated — auto-detect
632
+                let auto_animate = source_lower.ends_with(".gif")
631633
                     || source_lower.contains(".gif?")
632634
                     || source_lower.contains("/gif/")
633635
                     || source_lower.ends_with(".webp")
634636
                     || source_lower.contains(".webp?")
635637
                     || source_lower.contains("/webp/")
636638
                     || source_lower.ends_with(".apng")
637
-                    || source_lower.ends_with(".png")  // PNG might be APNG
638639
                     || source_lower.contains(".apng?")
639
-                    // Video formats
640640
                     || source_lower.ends_with(".mp4")
641641
                     || source_lower.ends_with(".webm")
642642
                     || source_lower.ends_with(".mkv")
@@ -644,16 +644,11 @@ impl Daemon {
644644
                     || source_lower.ends_with(".mov")
645645
                     || source_lower.ends_with(".m4v");
646646
 
647
-                // Videos should always be animated (no sense displaying a single frame)
648
-                let is_video = source_lower.ends_with(".mp4")
649
-                    || source_lower.ends_with(".webm")
650
-                    || source_lower.ends_with(".mkv")
651
-                    || source_lower.ends_with(".avi")
652
-                    || source_lower.ends_with(".mov")
653
-                    || source_lower.ends_with(".m4v");
647
+                // PNG needs explicit --animate (most PNGs aren't APNG)
648
+                let png_animate = animate && (source_lower.ends_with(".png"));
654649
 
655
-                // Auto-animate videos, or animate if flag is set for other formats
656
-                let should_animate = is_video || (animate && is_animatable);
650
+                // Auto-animate known formats; --animate forces attempt on .png
651
+                let should_animate = auto_animate || png_animate;
657652
 
658653
                 if should_animate {
659654
                     // Try to start animation