From 4fac2f05da4273c07ffbc81236116149f86e39bb Mon Sep 17 00:00:00 2001 From: Sho Date: Sun, 2 Aug 2026 02:08:11 +0900 Subject: [PATCH] fix: resolve Spectacle clicks and eliminate startup race condition causing wallpaper reset on reboot --- quickshell/modules/topbar/TopRightBar.qml | 10 +++++----- quickshell/services/CaptureService.qml | 22 ++++++---------------- quickshell/services/WallpaperService.qml | 9 +++++++-- quickshell/theme/Theme.qml | 22 ++++++++++++---------- 4 files changed, 30 insertions(+), 33 deletions(-) diff --git a/quickshell/modules/topbar/TopRightBar.qml b/quickshell/modules/topbar/TopRightBar.qml index c8ebecf..2392cb6 100644 --- a/quickshell/modules/topbar/TopRightBar.qml +++ b/quickshell/modules/topbar/TopRightBar.qml @@ -473,7 +473,7 @@ GlassPanel { hoverEnabled: true onClicked: { PopupService.closeAll() - ScreenshotService.captureRegion() + CaptureService.captureRegion() } } } @@ -504,7 +504,7 @@ GlassPanel { hoverEnabled: true onClicked: { PopupService.closeAll() - ScreenshotService.captureFullscreen() + CaptureService.captureFullscreen() } } } @@ -535,7 +535,7 @@ GlassPanel { hoverEnabled: true onClicked: { PopupService.closeAll() - ScreenshotService.captureWindow() + CaptureService.captureWindow() } } } @@ -586,7 +586,7 @@ GlassPanel { hoverEnabled: true onClicked: { PopupService.closeAll() - ScreenshotService.recordRegion() + CaptureService.recordRegion() } } } @@ -617,7 +617,7 @@ GlassPanel { hoverEnabled: true onClicked: { PopupService.closeAll() - ScreenshotService.recordScreen() + CaptureService.recordScreen() } } } diff --git a/quickshell/services/CaptureService.qml b/quickshell/services/CaptureService.qml index d9e257b..63fb627 100644 --- a/quickshell/services/CaptureService.qml +++ b/quickshell/services/CaptureService.qml @@ -7,43 +7,33 @@ pragma Singleton Item { id: root - Process { - id: execProc - } - function captureRegion() { PopupService.closeAll() - execProc.command = ["spectacle", "-r"] - execProc.running = true + Quickshell.execDetached(["spectacle", "-r"]) } function captureFullscreen() { PopupService.closeAll() - execProc.command = ["spectacle", "-f", "-b", "-c"] - execProc.running = true + Quickshell.execDetached(["spectacle", "-f", "-b", "-c"]) } function captureWindow() { PopupService.closeAll() - execProc.command = ["spectacle", "-a", "-b", "-c"] - execProc.running = true + Quickshell.execDetached(["spectacle", "-a", "-b", "-c"]) } function recordRegion() { PopupService.closeAll() - execProc.command = ["spectacle", "-R", "r"] - execProc.running = true + Quickshell.execDetached(["spectacle", "-R", "r"]) } function recordScreen() { PopupService.closeAll() - execProc.command = ["spectacle", "-R", "s"] - execProc.running = true + Quickshell.execDetached(["spectacle", "-R", "s"]) } function openGui() { PopupService.closeAll() - execProc.command = ["spectacle", "-g"] - execProc.running = true + Quickshell.execDetached(["spectacle", "-g"]) } } diff --git a/quickshell/services/WallpaperService.qml b/quickshell/services/WallpaperService.qml index c51b6dd..348057f 100644 --- a/quickshell/services/WallpaperService.qml +++ b/quickshell/services/WallpaperService.qml @@ -10,6 +10,7 @@ Item { property var wallpapers: [] property string activeCustomWallpaper: "" property var cachedThemeWallpapers: ({}) + property bool isLoaded: false // Automatic recolor watcher background daemon Process { @@ -40,6 +41,7 @@ Item { } } } catch (e) {} + root.isLoaded = true } } } @@ -74,7 +76,7 @@ Item { scanProc.running = true } - function applyWallpaper(filePath, variantName) { + function applyWallpaper(filePath, variantName, skipSave) { if (!filePath) return; let vName = variantName || (Theme ? Theme.currentVariant : "") activeCustomWallpaper = filePath @@ -89,7 +91,10 @@ Item { } Quickshell.execDetached(["plasma-apply-wallpaperimage", rawPath]) - Quickshell.execDetached(["python3", Quickshell.env("HOME") + "/.config/quickshell/services/python/save_wallpaper.py", rawPath, vName]) + + if (!skipSave) { + Quickshell.execDetached(["python3", Quickshell.env("HOME") + "/.config/quickshell/services/python/save_wallpaper.py", rawPath, vName]) + } } function refresh() { diff --git a/quickshell/theme/Theme.qml b/quickshell/theme/Theme.qml index 0714d93..8918f11 100644 --- a/quickshell/theme/Theme.qml +++ b/quickshell/theme/Theme.qml @@ -103,7 +103,7 @@ Item { property int blurRadius: 0 property int cornerRadius: 10 - function setVariant(name) { + function setVariant(name, isStartupRestoration) { for (let i = 0; i < variants.length; i++) { let v = variants[i] if (v.name === name) { @@ -164,16 +164,18 @@ Item { AppLauncherService.reload() - let imgPath = getVariantWallpaper(v.name) - if (WallpaperService) { - WallpaperService.applyWallpaper(imgPath, v.name) - } else { - wallpaperPath = imgPath.startsWith("file://") ? imgPath : "file://" + imgPath + if (!isStartupRestoration) { + let imgPath = getVariantWallpaper(v.name) + if (WallpaperService) { + WallpaperService.applyWallpaper(imgPath, v.name) + } else { + wallpaperPath = imgPath.startsWith("file://") ? imgPath : "file://" + imgPath + let rawPath = imgPath.replace("file://", "") + Quickshell.execDetached(["plasma-apply-wallpaperimage", rawPath]) + } let rawPath = imgPath.replace("file://", "") - Quickshell.execDetached(["plasma-apply-wallpaperimage", rawPath]) + Quickshell.execDetached(["sh", "-c", "wallust run '" + rawPath + "' || ~/.cargo/bin/wallust run '" + rawPath + "' 2>/dev/null || true"]) } - let rawPath = imgPath.replace("file://", "") - Quickshell.execDetached(["sh", "-c", "wallust run '" + rawPath + "' || ~/.cargo/bin/wallust run '" + rawPath + "' 2>/dev/null || true"]) // Persist selected theme variant to disk Quickshell.execDetached(["sh", "-c", "echo '" + v.name + "' > ~/.config/quickshell_current_theme.txt"]) @@ -191,7 +193,7 @@ Item { onRead: data => { let saved = data.trim() if (saved && saved !== "" && saved !== root.currentVariant) { - root.setVariant(saved) + root.setVariant(saved, true) } } }