Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions wallcards/Wallcards.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Quickshell.Io
import Quickshell.Wayland
import Qt5Compat.GraphicalEffects
import Qt.labs.folderlistmodel
import qs.Commons

PanelWindow {
id: root
Expand Down Expand Up @@ -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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utils.wallpaperCommand already differentiates between video and image. The if/else is therefore not needed here.

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 ?? "";
Expand Down
8 changes: 4 additions & 4 deletions wallcards/src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}