diff --git a/wallcards/Wallcards.qml b/wallcards/Wallcards.qml index f47a5b697..043d78e54 100644 --- a/wallcards/Wallcards.qml +++ b/wallcards/Wallcards.qml @@ -10,6 +10,7 @@ import Quickshell.Io import Quickshell.Wayland import Qt5Compat.GraphicalEffects import Qt.labs.folderlistmodel +import qs.Commons PanelWindow { id: root @@ -43,20 +44,26 @@ PanelWindow { property int thumbnailRevision: thumbnailService.thumbnailRevision property int topBarHeight: pluginApi?.pluginSettings?.top_bar_height ?? pluginApi?.manifest?.metadata?.defaultSettings?.top_bar_height property int topBarRadius: Style.radiusM + property int duration: Settings.data.wallpaper.transitionDuration signal quitRequested function applyCurrentCard() { - var f = filteredFiles[cardDeck.currentIndex]; - if (!f) - return; - - applicant.command = ["bash", "-c", Utils.wallpaperCommand(f)]; - applicant.running = true; - - var wallpaperPath = f.isVideo ? f.thumbnail : f.filePath; - WallpaperService.changeWallpaper(wallpaperPath); - } + var f = filteredFiles[cardDeck.currentIndex]; + if (!f) + return; + + var wallpaperPath = f.isVideo ? f.thumbnail : f.filePath; + WallpaperService.changeWallpaper(wallpaperPath); + + if (f.isVideo) { + applicant.command = ["bash", "-c", Utils.wallpaperCommand(f, duration)]; + applicant.running = true; + } else { + applicant.command = ["bash", "-c", Utils.mpvpaperKill]; + applicant.running = true; + } + } function applyFilterToFiles() { var currentFile = filteredFiles[cardDeck.currentIndex]?.filePath ?? ""; diff --git a/wallcards/src/Utils.js b/wallcards/src/Utils.js index 7a451801c..08efec423 100644 --- a/wallcards/src/Utils.js +++ b/wallcards/src/Utils.js @@ -26,12 +26,12 @@ var mpvpaperOptions = [ "--tscale=oversample" ].join(" "); -function mpvpaperRun(filePath) { - return "mpvpaper -o '" + mpvpaperOptions + "' '*' \"" + filePath + "\" >/dev/null 2>&1 & disown"; +function mpvpaperRun(filePath, duration) { + return "sleep " + duration / 1000 + " && mpvpaper -o '" + mpvpaperOptions + "' '*' \"" + filePath + "\" >/dev/null 2>&1 & disown"; } -function wallpaperCommand(entry) { +function wallpaperCommand(entry, duration) { if (entry.isVideo) - return mpvpaperKill + "; " + mpvpaperRun(entry.filePath); + return mpvpaperKill + "; " + mpvpaperRun(entry.filePath, duration); return mpvpaperKill; }