From c42681b9b9cb22f201b12069ad460c32d223724f Mon Sep 17 00:00:00 2001 From: bbedward Date: Fri, 12 Sep 2025 12:37:06 -0400 Subject: [PATCH] hide wallpaper engine unless they are available --- Modals/FileBrowser/FileBrowserModal.qml | 106 ++++++++++++++++++++---- Modules/Settings/PersonalizationTab.qml | 72 +++------------- Modules/WallpaperEngineProc.qml | 17 ++-- 3 files changed, 104 insertions(+), 91 deletions(-) diff --git a/Modals/FileBrowser/FileBrowserModal.qml b/Modals/FileBrowser/FileBrowserModal.qml index de096207..81c6a7f6 100644 --- a/Modals/FileBrowser/FileBrowserModal.qml +++ b/Modals/FileBrowser/FileBrowserModal.qml @@ -32,6 +32,9 @@ DankModal { property bool selectedFileIsDir: false property bool showOverwriteConfirmation: false property string pendingFilePath: "" + property bool weAvailable: false + property string wePath: "" + property bool weMode: false signal fileSelected(string path) @@ -131,6 +134,31 @@ DankModal { Component.onCompleted: { currentPath = getLastPath() } + + property var steamPaths: [ + StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.steam/steam/steamapps/workshop/content/431960", + StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.local/share/Steam/steamapps/workshop/content/431960", + StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/workshop/content/431960", + StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/snap/steam/common/.local/share/Steam/steamapps/workshop/content/431960" + ] + property int currentPathIndex: 0 + + function discoverWallpaperEngine() { + currentPathIndex = 0 + checkNextPath() + } + + function checkNextPath() { + if (currentPathIndex >= steamPaths.length) { + return + } + + const wePath = steamPaths[currentPathIndex] + const cleanPath = wePath.replace(/^file:\/\//, '') + weDiscoveryProcess.command = ["test", "-d", cleanPath] + weDiscoveryProcess.wePath = wePath + weDiscoveryProcess.running = true + } width: 800 height: 600 enableShadow: true @@ -148,6 +176,9 @@ DankModal { selectedIndex = -1 keyboardNavigationActive = false backButtonFocused = false + if (browserType === "wallpaper" && !weAvailable) { + discoverWallpaperEngine() + } } } onCurrentPathChanged: { @@ -334,6 +365,23 @@ DankModal { executeKeyboardSelection(targetIndex) } } + + Process { + id: weDiscoveryProcess + + property string wePath: "" + running: false + + onExited: exitCode => { + if (exitCode === 0) { + fileBrowserModal.weAvailable = true + fileBrowserModal.wePath = wePath + } else { + currentPathIndex++ + checkNextPath() + } + } + } content: Component { Item { @@ -373,6 +421,22 @@ DankModal { anchors.verticalCenter: parent.verticalCenter spacing: Theme.spacingS + DankActionButton { + circular: false + iconName: "movie" + iconSize: Theme.iconSize - 4 + iconColor: weMode ? Theme.primary : Theme.surfaceText + visible: weAvailable && browserType === "wallpaper" + onClicked: { + weMode = !weMode + if (weMode) { + navigateTo(wePath) + } else { + navigateTo(getLastPath()) + } + } + } + DankActionButton { circular: false iconName: "info" @@ -439,8 +503,8 @@ DankModal { width: parent.width height: parent.height - 80 clip: true - cellWidth: fileBrowserModal.browserType === "we" ? 255 : 150 - cellHeight: fileBrowserModal.browserType === "we" ? 215 : 130 + cellWidth: weMode ? 255 : 150 + cellHeight: weMode ? 215 : 130 cacheBuffer: 260 model: folderModel currentIndex: selectedIndex @@ -466,8 +530,8 @@ DankModal { required property url fileURL required property int index - width: fileBrowserModal.browserType === "we" ? 245 : 140 - height: fileBrowserModal.browserType === "we" ? 205 : 120 + width: weMode ? 245 : 140 + height: weMode ? 205 : 120 radius: Theme.cornerRadius color: { if (keyboardNavigationActive && delegateRoot.index === selectedIndex) @@ -498,31 +562,33 @@ DankModal { spacing: Theme.spacingXS Item { - width: fileBrowserModal.browserType === "we" ? 225 : 80 - height: fileBrowserModal.browserType === "we" ? 165 : 60 + width: weMode ? 225 : 80 + height: weMode ? 165 : 60 anchors.horizontalCenter: parent.horizontalCenter CachingImage { anchors.fill: parent - property var weExtensions: [".jpg", ".png", ".webp", ".gif", ".jpeg"] + property var weExtensions: [".jpg", ".jpeg", ".png", ".webp", ".gif", ".bmp", ".tga"] property int weExtIndex: 0 source: { - if (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir) { + if (weMode && delegateRoot.fileIsDir) { return "file://" + delegateRoot.filePath + "/preview" + weExtensions[weExtIndex] } return (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) ? ("file://" + delegateRoot.filePath) : "" } onStatusChanged: { - if (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir && status === Image.Error) { + if (weMode && delegateRoot.fileIsDir && status === Image.Error) { if (weExtIndex < weExtensions.length - 1) { weExtIndex++ source = "file://" + delegateRoot.filePath + "/preview" + weExtensions[weExtIndex] + } else { + source = "" } } } fillMode: Image.PreserveAspectCrop - visible: (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) || (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir) - maxCacheSize: fileBrowserModal.browserType === "we" ? 225 : 80 + visible: (!delegateRoot.fileIsDir && isImageFile(delegateRoot.fileName)) || (weMode && delegateRoot.fileIsDir) + maxCacheSize: weMode ? 225 : 80 } DankIcon { @@ -538,7 +604,7 @@ DankModal { name: "folder" size: Theme.iconSizeLarge color: Theme.primary - visible: delegateRoot.fileIsDir && fileBrowserModal.browserType !== "we" + visible: delegateRoot.fileIsDir && !weMode } } @@ -565,15 +631,15 @@ DankModal { // Update selected file info and index first selectedIndex = delegateRoot.index setSelectedFileData(delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir) - if (fileBrowserModal.browserType === "we" && delegateRoot.fileIsDir) { - // Select this folder instead of navigating inside - fileSelected(delegateRoot.filePath) + if (weMode && delegateRoot.fileIsDir) { + var sceneId = delegateRoot.filePath.split("/").pop() + fileSelected("we:" + sceneId) fileBrowserModal.close() - } if (delegateRoot.fileIsDir) { + } else if (delegateRoot.fileIsDir) { navigateTo(delegateRoot.filePath) } else { fileSelected(delegateRoot.filePath) - fileBrowserModal.close() // Close modal after file selection + fileBrowserModal.close() } } } @@ -585,7 +651,11 @@ DankModal { fileBrowserModal.keyboardSelectionRequested = false selectedIndex = delegateRoot.index setSelectedFileData(delegateRoot.filePath, delegateRoot.fileName, delegateRoot.fileIsDir) - if (delegateRoot.fileIsDir) { + if (weMode && delegateRoot.fileIsDir) { + var sceneId = delegateRoot.filePath.split("/").pop() + fileSelected("we:" + sceneId) + fileBrowserModal.close() + } else if (delegateRoot.fileIsDir) { navigateTo(delegateRoot.filePath) } else { fileSelected(delegateRoot.filePath) diff --git a/Modules/Settings/PersonalizationTab.qml b/Modules/Settings/PersonalizationTab.qml index f8fe8503..2c32bfdc 100644 --- a/Modules/Settings/PersonalizationTab.qml +++ b/Modules/Settings/PersonalizationTab.qml @@ -142,7 +142,7 @@ Item { CachingImage { anchors.fill: parent anchors.margins: 1 - property var weExtensions: [".jpg", ".png", ".webp", ".gif", ".jpeg"] + property var weExtensions: [".jpg", ".jpeg", ".png", ".webp", ".gif", ".bmp", ".tga"] property int weExtIndex: 0 source: { var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath @@ -156,12 +156,16 @@ Item { } onStatusChanged: { var currentWallpaper = SessionData.perMonitorWallpaper ? SessionData.getMonitorWallpaper(selectedMonitorName) : SessionData.wallpaperPath - if (currentWallpaper.startsWith("we:") && status === Image.Error && weExtIndex < weExtensions.length - 1) { - weExtIndex++ - source = StandardPaths.writableLocation(StandardPaths.HomeLocation) - + "/.local/share/Steam/steamapps/workshop/content/431960/" - + currentWallpaper.substring(3) - + "/preview" + weExtensions[weExtIndex] + if (currentWallpaper && currentWallpaper.startsWith("we:") && status === Image.Error) { + if (weExtIndex < weExtensions.length - 1) { + weExtIndex++ + source = StandardPaths.writableLocation(StandardPaths.HomeLocation) + + "/.local/share/Steam/steamapps/workshop/content/431960/" + + currentWallpaper.substring(3) + + "/preview" + weExtensions[weExtIndex] + } else { + visible = false + } } } fillMode: Image.PreserveAspectCrop @@ -253,29 +257,6 @@ Item { } } - Rectangle { - width: 32; height: 32; radius: 16 - color: Qt.rgba(255, 255, 255, 0.9) - - DankIcon { - anchors.centerIn: parent - name: "movie" // 🎬 icon for WE - size: 18 - color: "black" - } - - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - if (parentModal) { - parentModal.allowFocusOverride = true - parentModal.shouldHaveFocus = false - } - weBrowser.open() - } - } - } Rectangle { width: 32 @@ -1467,37 +1448,6 @@ Item { } } - FileBrowserModal { - id: weBrowser - browserTitle: "Select Wallpaper Engine Scene" - browserIcon: "movie" - browserType: "we" - fileExtensions: [] // only show dirs - - // override homeDir to point to Steam workshop path - homeDir: StandardPaths.writableLocation(StandardPaths.HomeLocation) - + "/.local/share/Steam/steamapps/workshop/content/431960" - - // ensure we start there - Component.onCompleted: currentPath = homeDir - - function getLastPath() { - return homeDir - } - - onFileSelected: folderPath => { - var sceneId = folderPath.split("/").pop() - var weSource = "we:" + sceneId - if (SessionData.perMonitorWallpaper) { - SessionData.setMonitorWallpaper(selectedMonitorName, weSource) - } else { - SessionData.setWallpaper(weSource) - } - close() - } - } - - DankColorPicker { id: colorPicker diff --git a/Modules/WallpaperEngineProc.qml b/Modules/WallpaperEngineProc.qml index 506c2aa2..b002ae10 100644 --- a/Modules/WallpaperEngineProc.qml +++ b/Modules/WallpaperEngineProc.qml @@ -21,30 +21,23 @@ Item { command: [] onExited: (code) => { if (pendingSceneId !== "") { - const cacheHome = StandardPaths.writableLocation(StandardPaths.CacheLocation).toString() - const baseDir = cacheHome.startsWith("file://") ? cacheHome.substring(7) : cacheHome - const outDir = baseDir + "/dankshell/we_screenshots" - const outPath = outDir + "/" + pendingSceneId + ".jpg" - - Quickshell.execDetached(["mkdir", "-p", outDir]) - - // only spawn after killer has done its job weProcess.command = [ "linux-wallpaperengine", "--screen-root", monitor, - "--screenshot", - outPath, - pendingSceneId, + "--bg", pendingSceneId, "--silent" ] weProcess.running = true + sceneId = pendingSceneId pendingSceneId = "" } } } function start(newSceneId) { - sceneId = newSceneId + if (sceneId === newSceneId && weProcess.running) { + return + } pendingSceneId = newSceneId stop() }