From b02d9fd3671954ea080d49b09136576961ba8323 Mon Sep 17 00:00:00 2001 From: Chintan Patel <216989679+Chintanpatel24@users.noreply.github.com> Date: Wed, 21 Oct 2026 23:19:18 +0530 Subject: [PATCH 1/3] feat(wallpaper): custom folder and desktop background cycling support --- crates/agilityd/src/modules/theme.rs | 51 +++++-- .../agility/Core/Services/HyprlandService.qml | 3 + .../agility/Core/Services/SettingsService.qml | 12 ++ .../Core/Services/WallpaperManager.qml | 138 +++++++++++++++--- .../WallpaperSettings/WallpaperSettings.qml | 113 +++++++++++++- .../Components/WallpaperCardDelegate.qml | 5 +- .../WallpaperSelectorContent.qml | 24 ++- scripts/restart.sh | 8 +- 8 files changed, 314 insertions(+), 40 deletions(-) diff --git a/crates/agilityd/src/modules/theme.rs b/crates/agilityd/src/modules/theme.rs index 2534e2d9..71fe38d7 100644 --- a/crates/agilityd/src/modules/theme.rs +++ b/crates/agilityd/src/modules/theme.rs @@ -39,6 +39,22 @@ pub fn expand_tilde(path_str: &str) -> PathBuf { PathBuf::from(trimmed) } +fn get_custom_wallpaper_dir() -> Option { + let home = std::env::var("HOME").ok()?; + let prefs_path = PathBuf::from(&home).join(".cache/quickshell/settings_prefs.json"); + let content = fs::read_to_string(&prefs_path).ok()?; + let val: serde_json::Value = serde_json::from_str(&content).ok()?; + if val.get("wpSourceMode").and_then(|v| v.as_str()) == Some("custom") { + if let Some(folder) = val.get("wpCustomFolderPath").and_then(|v| v.as_str()) { + let expanded = expand_tilde(folder); + if expanded.is_dir() { + return Some(expanded); + } + } + } + None +} + /// Resolve wallpaper path across common candidate search paths if not found directly. pub fn resolve_wallpaper_path(path_str: &str) -> Option { let trimmed = path_str.trim(); @@ -54,6 +70,10 @@ pub fn resolve_wallpaper_path(path_str: &str) -> Option { let file_name = direct.file_name()?.to_str()?; let mut search_dirs = Vec::new(); + if let Some(custom_dir) = get_custom_wallpaper_dir() { + search_dirs.push(custom_dir); + } + if let Ok(home) = std::env::var("HOME") { search_dirs.push(PathBuf::from(&home).join(".local/share/agility-shell/wallpapers")); search_dirs.push(PathBuf::from(&home).join(".config/agility-shell/wallpapers")); @@ -79,17 +99,22 @@ pub fn resolve_wallpaper_path(path_str: &str) -> Option { /// Discover all available wallpaper image files across candidate directories. pub fn list_all_wallpapers() -> Vec { let mut search_dirs = Vec::new(); - if let Ok(home) = std::env::var("HOME") { - search_dirs.push(PathBuf::from(&home).join(".local/share/agility-shell/wallpapers")); - search_dirs.push(PathBuf::from(&home).join(".config/agility-shell/wallpapers")); - search_dirs.push(PathBuf::from(&home).join("Pictures/Wallpapers")); - search_dirs.push(PathBuf::from(&home).join("Pictures")); - } - if let Ok(data_home) = std::env::var("XDG_DATA_HOME") { - search_dirs.push(PathBuf::from(&data_home).join("agility-shell/wallpapers")); + + if let Some(custom_dir) = get_custom_wallpaper_dir() { + search_dirs.push(custom_dir); + } else { + if let Ok(home) = std::env::var("HOME") { + search_dirs.push(PathBuf::from(&home).join(".local/share/agility-shell/wallpapers")); + search_dirs.push(PathBuf::from(&home).join(".config/agility-shell/wallpapers")); + search_dirs.push(PathBuf::from(&home).join("Pictures/Wallpapers")); + search_dirs.push(PathBuf::from(&home).join("Pictures")); + } + if let Ok(data_home) = std::env::var("XDG_DATA_HOME") { + search_dirs.push(PathBuf::from(&data_home).join("agility-shell/wallpapers")); + } + search_dirs.push(PathBuf::from("/usr/share/agility-shell/wallpapers")); + search_dirs.push(PathBuf::from("wallpapers")); } - search_dirs.push(PathBuf::from("/usr/share/agility-shell/wallpapers")); - search_dirs.push(PathBuf::from("wallpapers")); let mut found = Vec::new(); let mut seen_names = std::collections::HashSet::new(); @@ -309,7 +334,9 @@ impl ThemeService { // 1. Instantly dispatch wallpaper setter (awww / swww) in < 5ms let t_type = transition_type.unwrap_or("grow"); let t_dur = duration.unwrap_or(0.20); - Self::dispatch_wallpaper_backend(&abs_str, t_type, t_dur); + if t_type != "skip" { + Self::dispatch_wallpaper_backend(&abs_str, t_type, t_dur); + } // Immediate responsive token return with new wallpaper let mut tokens = self.tokens(); @@ -638,6 +665,8 @@ impl ThemeService { .arg("Bilinear") .arg("--transition-type") .arg(transition_type) + .arg("--transition-bezier") + .arg(".54,0,.34,.99") .arg("--transition-duration") .arg(&dur_str) .arg("--transition-step") diff --git a/quickshell/agility/Core/Services/HyprlandService.qml b/quickshell/agility/Core/Services/HyprlandService.qml index 25dbbe5e..7ae62dc5 100644 --- a/quickshell/agility/Core/Services/HyprlandService.qml +++ b/quickshell/agility/Core/Services/HyprlandService.qml @@ -22,6 +22,9 @@ Item { property int wpTransitionAngle: 30 property string wpResizeMode: "crop" property string wpCropGravity: "center" + property string wpSourceMode: "default" + property string wpCustomFolderPath: "" + property bool wpClicksEnabled: false property bool hyprBlur: true property int hyprRounding: Constants.size3Xl property int hyprActiveOpacity: 100 diff --git a/quickshell/agility/Core/Services/SettingsService.qml b/quickshell/agility/Core/Services/SettingsService.qml index a5e6e47c..3d9c9c51 100644 --- a/quickshell/agility/Core/Services/SettingsService.qml +++ b/quickshell/agility/Core/Services/SettingsService.qml @@ -297,6 +297,9 @@ Item { "wpTransitionAngle": HyprlandService.wpTransitionAngle, "wpResizeMode": HyprlandService.wpResizeMode, "wpCropGravity": HyprlandService.wpCropGravity, + "wpSourceMode": HyprlandService.wpSourceMode, + "wpCustomFolderPath": HyprlandService.wpCustomFolderPath, + "wpClicksEnabled": HyprlandService.wpClicksEnabled, "micMuted": AudioService.micMuted, "micVolume": AudioService.micVolume, "quoteCategory": settingsService.quoteCategory, @@ -454,6 +457,15 @@ cp ~/.cache/quickshell/settings_prefs.json /var/tmp/sddm-theme/settings_prefs.js if (prefs.wpCropGravity !== undefined) HyprlandService.wpCropGravity = prefs.wpCropGravity; + if (prefs.wpSourceMode !== undefined) + HyprlandService.wpSourceMode = prefs.wpSourceMode; + + if (prefs.wpCustomFolderPath !== undefined) + HyprlandService.wpCustomFolderPath = prefs.wpCustomFolderPath; + + if (prefs.wpClicksEnabled !== undefined) + HyprlandService.wpClicksEnabled = prefs.wpClicksEnabled; + if (prefs.micVolume !== undefined) { AudioService.micVolume = AudioService.hasPhysicalMic ? prefs.micVolume : 0; if (AudioService.hasPhysicalMic) diff --git a/quickshell/agility/Core/Services/WallpaperManager.qml b/quickshell/agility/Core/Services/WallpaperManager.qml index 091b840e..cbcd435b 100644 --- a/quickshell/agility/Core/Services/WallpaperManager.qml +++ b/quickshell/agility/Core/Services/WallpaperManager.qml @@ -20,17 +20,33 @@ QtObject { property bool enableTransitions: HyprlandService.wpEnableTransitions property bool autoShuffle: HyprlandService.wpAutoShuffle property int shuffleInterval: HyprlandService.wpShuffleInterval + + property var wallpaperList: [] + property int wallpaperListCount: wallpaperList.length + property Process fastAwwwProc property Process wallpaperApplyProc property Process wallpaperSaveProc property Process wallpaperLoader property Process randomWallpaperProc + property Process listLoaderProc property Timer shuffleTimer - function applyWallpaperWithSync(wallpaperName, rawPath) { + function setWallpaperList(list) { + if (!list) return; + wallpaperList = list; + } + + function reloadWallpaperList() { + listLoaderProc.lines = []; + listLoaderProc.running = false; + listLoaderProc.running = true; + } + + function applyWallpaperWithSync(wallpaperName, rawPath, transitionPos) { currentWallpaper = wallpaperName; currentWallpaperPath = rawPath; - applyWallpaper(rawPath); + applyWallpaper(rawPath, "", transitionPos); } function reapplyCurrentWallpaper() { @@ -39,11 +55,11 @@ QtObject { applyWallpaper(p); } - function applyWallpaperInstant(rawPath) { - applyWallpaper(rawPath); + function applyWallpaperInstant(rawPath, transitionPos) { + applyWallpaper(rawPath, "", transitionPos); } - function applyWallpaper(rawPath) { + function applyWallpaper(rawPath, forceTransitionType, transitionPos) { if (!rawPath) return; if (HyprlandService.wpAutoShuffle) { @@ -51,29 +67,77 @@ QtObject { SettingsService.saveSettings(); } - // Fast path: Immediately apply wallpaper with awww directly (< 250ms visual switch) + let chosenType = forceTransitionType || ((enableTransitions && SystemInfoService.powerProfile !== "power-saver" && transitionType) ? transitionType : "grow"); + let pos = transitionPos || transitionPos; + if (!pos) { + pos = (enableTransitions && HyprlandService.wpTransitionPos) ? HyprlandService.wpTransitionPos : "center"; + } + + // Fast path: Immediately apply wallpaper with awww directly (< 30ms visual switch) fastAwwwProc.running = false; - fastAwwwProc.command = [ + let awwwArgs = [ "awww", "img", rawPath, - "--resize", "crop", + "--resize", (resizeMode || "crop"), "--filter", "Bilinear", - "--transition-type", (enableTransitions && SystemInfoService.powerProfile !== "power-saver" && transitionType) ? transitionType : "grow", - "--transition-duration", "0.2", - "--transition-step", "180", - "--transition-fps", "60" + "--transition-type", chosenType, + "--transition-bezier", ".54,0,.34,.99", + "--transition-duration", "0.25", + "--transition-step", (transitionStep ? String(transitionStep) : "180"), + "--transition-fps", (transitionFps ? String(transitionFps) : "60") ]; + if (pos) { + if (pos.indexOf(',') !== -1) { + awwwArgs.push("--invert-y"); + } + awwwArgs.push("--transition-pos", pos); + } + if (chosenType === "wipe" || chosenType === "wave") { + awwwArgs.push("--transition-angle", String(transitionAngle || 30)); + } + fastAwwwProc.command = awwwArgs; fastAwwwProc.startDetached(); - // Daemon sync: extracts palette, generates blur, writes cache + // Daemon sync: extracts palette, generates blur, writes cache without double-running awww wallpaperApplyProc.running = false; - let cmd = ["agl", "wallpaper", rawPath, "--duration", "0.2"]; - if (enableTransitions && SystemInfoService.powerProfile !== "power-saver" && transitionType) { - cmd.push("--transition", transitionType); - } + let cmd = ["agl", "wallpaper", rawPath, "--skip-backend"]; wallpaperApplyProc.command = cmd; wallpaperApplyProc.startDetached(); } + function cycleNextWallpaper(screenX, screenY, screenWidth, screenHeight) { + if (!wallpaperList || wallpaperList.length === 0) { + reloadWallpaperList(); + randomWallpaperProc.running = false; + randomWallpaperProc.running = true; + return; + } + + let cur = currentWallpaper ? currentWallpaper.trim() : ""; + let curPath = currentWallpaperPath ? currentWallpaperPath.trim() : ""; + let curIdx = -1; + + for (let i = 0; i < wallpaperList.length; i++) { + if (wallpaperList[i].rawPath === curPath || wallpaperList[i].name === cur) { + curIdx = i; + break; + } + } + + let nextIdx = (curIdx + 1) % wallpaperList.length; + let nextWall = wallpaperList[nextIdx]; + if (!nextWall) + return; + + currentWallpaper = nextWall.name; + currentWallpaperPath = nextWall.rawPath; + + let posStr = (screenX !== undefined && screenY !== undefined) + ? (Math.round(screenX) + "," + Math.round(screenY)) + : "center"; + + applyWallpaper(nextWall.rawPath, "grow", posStr); + } + function saveCurrentWallpaper(wallName) { // Handled automatically by agl wallpaper } @@ -87,6 +151,7 @@ QtObject { Component.onCompleted: { wallpaperLoader.running = true; + reloadWallpaperList(); } shuffleTimer: Timer { @@ -108,6 +173,45 @@ QtObject { wallpaperSaveProc: Process { } + listLoaderProc: Process { + property var lines: [] + command: ["agl", "wallpaper", "list"] + onExited: function(exitCode) { + let seen = {}; + let uniqueList = []; + for (let i = 0; i < lines.length; i++) { + let item = lines[i]; + if (!seen[item.name]) { + seen[item.name] = true; + uniqueList.push(item); + } + } + uniqueList.sort(function(a, b) { + return a.name.localeCompare(b.name); + }); + root.wallpaperList = uniqueList; + lines = []; + } + + stdout: SplitParser { + onRead: function(data) { + let linesArr = data.split('\n'); + for (let i = 0; i < linesArr.length; i++) { + let rawPath = linesArr[i].trim(); + if (rawPath !== "") { + let parts = rawPath.split('/'); + let fileName = parts[parts.length - 1]; + listLoaderProc.lines.push({ + "filePath": "file://" + rawPath, + "rawPath": rawPath, + "name": fileName + }); + } + } + } + } + } + randomWallpaperProc: Process { command: ["agl", "wallpaper", "random"] onExited: function(exitCode) { diff --git a/quickshell/agility/Modules/Settings/WallpaperSettings/WallpaperSettings.qml b/quickshell/agility/Modules/Settings/WallpaperSettings/WallpaperSettings.qml index 94b710c6..2bdbe98f 100644 --- a/quickshell/agility/Modules/Settings/WallpaperSettings/WallpaperSettings.qml +++ b/quickshell/agility/Modules/Settings/WallpaperSettings/WallpaperSettings.qml @@ -12,6 +12,98 @@ import qs.Modules.Settings.Components AppContainer { id: wallpaperRoot + Process { + id: folderPickerProc + + command: ["sh", "-c", "zenity --file-selection --directory --title='Select Wallpapers Folder' 2>/dev/null || true"] + onExited: function(exitCode) { + let path = pickerOutput.text.trim(); + if (path && path !== "") { + HyprlandService.wpCustomFolderPath = path; + SettingsService.saveSettings(); + WallpaperManager.reloadWallpaperList(); + } + } + + stdout: StdioCollector { + id: pickerOutput + } + } + + AppGroup { + title: "Wallpaper Source & Library" + icon: "folder" + + SettingSegmented { + label: "Wallpaper Source" + description: "Choose whether to use system default wallpapers or a custom folder" + model: [{ + "text": "Default", + "value": "default" + }, { + "text": "Custom Folder", + "value": "custom" + }] + currentValue: HyprlandService.wpSourceMode + onActivated: (val) => { + HyprlandService.wpSourceMode = val; + SettingsService.saveSettings(); + WallpaperManager.reloadWallpaperList(); + } + } + + ColumnLayout { + spacing: Constants.sizeSm + Layout.fillWidth: true + visible: HyprlandService.wpSourceMode === "custom" + + RowLayout { + spacing: Constants.sizeSm + Layout.fillWidth: true + + ThemedTextField { + id: customFolderInput + + Layout.fillWidth: true + label: "Folder Path" + placeholderText: "Path to wallpapers folder (e.g. ~/Pictures/Wallpapers)" + text: HyprlandService.wpCustomFolderPath + onEditingFinished: { + if (text.trim() !== HyprlandService.wpCustomFolderPath) { + HyprlandService.wpCustomFolderPath = text.trim(); + SettingsService.saveSettings(); + WallpaperManager.reloadWallpaperList(); + } + } + } + + SvgIconButton { + Layout.alignment: Qt.AlignBottom + icon: "folder" + textIcon: "Browse" + textIconSize: Constants.sizeSm + useCustomWidth: true + onClicked: { + folderPickerProc.running = false; + folderPickerProc.running = true; + } + } + } + + ThemedText { + text: { + if (WallpaperManager.wallpaperListCount > 0) + return WallpaperManager.wallpaperListCount + " wallpapers loaded from active folder"; + if (!HyprlandService.wpCustomFolderPath) + return "Please select or type a folder path"; + return "No image files (.png, .jpg, .webp, .gif) found in this folder"; + } + color: WallpaperManager.wallpaperListCount > 0 ? Theme.accent : Theme.muted + customSize: Constants.sizeSm + } + } + } + AppGroup { title: "Screen Framing & Cropping" icon: "picture-spark" @@ -46,6 +138,25 @@ AppContainer { title: "Automation & Transitions" icon: "sparkles" + SettingToggle { + id: clicksToggle + + label: "Desktop Double-Click (clicks)" + description: "Double-click anywhere on the empty desktop to switch wallpaper" + onCheckedChanged: { + if (checked !== HyprlandService.wpClicksEnabled) { + HyprlandService.wpClicksEnabled = checked; + SettingsService.saveSettings(); + } + } + + Binding { + target: clicksToggle + property: "checked" + value: HyprlandService.wpClicksEnabled + } + } + SettingToggle { id: autoShuffleToggle @@ -81,7 +192,7 @@ AppContainer { ThemedSelect { label: "Transition Type" - model: ["none", "grow", "fade", "wipe", "wave", "random"] + model: ["none", "grow", "outer", "center", "fade", "wipe", "wave", "random"] currentIndex: { if (!HyprlandService.wpEnableTransitions) return 0; diff --git a/quickshell/agility/Modules/WallpaperSelector/Components/WallpaperCardDelegate.qml b/quickshell/agility/Modules/WallpaperSelector/Components/WallpaperCardDelegate.qml index 5a8dd442..e0b3dbe2 100644 --- a/quickshell/agility/Modules/WallpaperSelector/Components/WallpaperCardDelegate.qml +++ b/quickshell/agility/Modules/WallpaperSelector/Components/WallpaperCardDelegate.qml @@ -157,13 +157,14 @@ Item { } TapHandler { - onTapped: { + onTapped: (eventPoint) => { if (delegateRoot.targetView) delegateRoot.targetView.currentIndex = delegateRoot.index; if (delegateRoot.selectorRoot) { delegateRoot.selectorRoot.ensureVisible(delegateRoot.index); - delegateRoot.selectorRoot.setWallpaper(delegateRoot.rawPath); + let gPos = delegateRoot.mapToGlobal(eventPoint.position.x, eventPoint.position.y); + delegateRoot.selectorRoot.setWallpaper(delegateRoot.rawPath, gPos.x, gPos.y); } } } diff --git a/quickshell/agility/Modules/WallpaperSelector/WallpaperSelectorContent.qml b/quickshell/agility/Modules/WallpaperSelector/WallpaperSelectorContent.qml index 4371ebd6..83c3772f 100644 --- a/quickshell/agility/Modules/WallpaperSelector/WallpaperSelectorContent.qml +++ b/quickshell/agility/Modules/WallpaperSelector/WallpaperSelectorContent.qml @@ -125,13 +125,17 @@ Item { wallView.currentIndex = -1; } - function setWallpaper(targetPath) { + function setWallpaper(targetPath, clickX, clickY) { if (!targetPath) return ; let parts = targetPath.split('/'); let wallName = parts[parts.length - 1]; - WallpaperManager.applyWallpaperWithSync(wallName, targetPath); + let posStr = ""; + if (clickX !== undefined && clickY !== undefined) { + posStr = Math.round(clickX) + "," + Math.round(clickY); + } + WallpaperManager.applyWallpaperWithSync(wallName, targetPath, posStr); if (root.widget && root.widget.close !== undefined) root.widget.close(); else if (root.widget && root.widget.isOpen !== undefined) @@ -187,14 +191,21 @@ Item { property var lines: [] - command: ["sh", "-c", "agl wallpaper list 2>/dev/null; find ~/.local/share/agility-shell/wallpapers ~/.config/agility-shell/wallpapers ~/Pictures/Wallpapers -maxdepth 1 -type f \\( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' -o -iname '*.gif' \\) 2>/dev/null"] + command: { + if (HyprlandService.wpSourceMode === "custom" && HyprlandService.wpCustomFolderPath) { + let folder = HyprlandService.wpCustomFolderPath.replace(/^~/, "$HOME"); + return ["sh", "-c", "find \"" + folder + "\" -maxdepth 1 -type f \\( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' -o -iname '*.gif' \\) 2>/dev/null"]; + } else { + return ["sh", "-c", "agl wallpaper list 2>/dev/null || find ~/.local/share/agility-shell/wallpapers ~/.config/agility-shell/wallpapers ~/Pictures/Wallpapers -maxdepth 1 -type f \\( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.webp' -o -iname '*.gif' \\) 2>/dev/null"]; + } + } onExited: function(exitCode) { - let seen = {}; + let seenNames = {}; let uniqueLines = []; for (let i = 0; i < lines.length; i++) { let item = lines[i]; - if (!seen[item.rawPath]) { - seen[item.rawPath] = true; + if (!seenNames[item.name]) { + seenNames[item.name] = true; uniqueLines.push(item); } } @@ -217,6 +228,7 @@ Item { } filterWallpapers(searchField.text); } + WallpaperManager.setWallpaperList(sortedLines); lines = []; } diff --git a/scripts/restart.sh b/scripts/restart.sh index 3de7514a..f3f956de 100755 --- a/scripts/restart.sh +++ b/scripts/restart.sh @@ -49,11 +49,13 @@ fi info "Gracefully restarting Agility Shell Next-Gen..." -# Terminate existing quickshell and agilityd instances safely -killall -q -15 quickshell 2>/dev/null || true +# Terminate existing agility quickshell and agilityd instances safely +pkill -f "quickshell.*agility" 2>/dev/null || true +pkill -f "agility.*shell.qml" 2>/dev/null || true killall -q -15 agilityd 2>/dev/null || true sleep 0.015 -killall -q -9 quickshell 2>/dev/null || true +pkill -9 -f "quickshell.*agility" 2>/dev/null || true +pkill -9 -f "agility.*shell.qml" 2>/dev/null || true killall -q -9 agilityd 2>/dev/null || true # Determine launcher or shell script From 16bc74aa42223c39bbceab085685efe6b9de2e97 Mon Sep 17 00:00:00 2001 From: Chintan Patel <216989679+Chintanpatel24@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:04:26 +0530 Subject: [PATCH 2/3] feat(core, quickshell): isolate quickshell instance runtime and process management --- agility-shell | 4 +- crates/agility-cli/src/main.rs | 195 ++++++++++++++++++++++++--------- quickshell/agility/shell.qml | 32 ++++++ 3 files changed, 179 insertions(+), 52 deletions(-) diff --git a/agility-shell b/agility-shell index 6e540720..eede3439 100755 --- a/agility-shell +++ b/agility-shell @@ -39,11 +39,11 @@ for cand in \ done # If already running: toggle launcher/dashboard -if pgrep -x "quickshell" >/dev/null 2>&1; then +if pgrep -f "quickshell.*agility" >/dev/null 2>&1 || pgrep -f "agility.*shell.qml" >/dev/null 2>&1; then if command -v agl >/dev/null 2>&1; then agl toggle launcher >/dev/null 2>&1 || true elif command -v qs >/dev/null 2>&1; then - qs ipc call launcher toggle >/dev/null 2>&1 || true + qs ipc -i agility-shell call launcher toggle >/dev/null 2>&1 || true elif [[ -x "$SELF_DIR/target/release/agl" ]]; then "$SELF_DIR/target/release/agl" toggle launcher >/dev/null 2>&1 || true fi diff --git a/crates/agility-cli/src/main.rs b/crates/agility-cli/src/main.rs index e8e4fa19..01709792 100644 --- a/crates/agility-cli/src/main.rs +++ b/crates/agility-cli/src/main.rs @@ -168,6 +168,12 @@ enum Commands { /// Optional transition duration in seconds #[arg(long)] duration: Option, + /// Optional transition center position (e.g. "center" or "500,300") + #[arg(long)] + pos: Option, + /// Skip awww dispatch if already dispatched by fast path + #[arg(long)] + skip_backend: bool, /// Output list in JSON format #[arg(long)] json: bool, @@ -206,8 +212,20 @@ async fn main() -> Result<()> { action, transition, duration, + pos, + skip_backend, json, - } => handle_wallpaper(&action, transition.as_deref(), duration, json).await?, + } => { + handle_wallpaper( + &action, + transition.as_deref(), + duration, + pos.as_deref(), + skip_backend, + json, + ) + .await? + } Commands::Auth { args } => { std::process::exit(tools::auth::run(&args)); } @@ -331,9 +349,9 @@ async fn handle_start(legacy: bool) -> Result<()> { println!("✓ Spawned awww-daemon."); } - let quickshell_pid = get_process_pid("quickshell"); + let quickshell_pid = get_agility_quickshell_pid(); if let Some(pid) = quickshell_pid { - println!("ℹ quickshell is already running (PID: {pid})."); + println!("ℹ quickshell (agility) is already running (PID: {pid})."); } else { let shell_qml = locate_shell_qml(); if let Some(path) = shell_qml { @@ -379,8 +397,13 @@ async fn handle_stop() -> Result<()> { .status(); } - // Gracefully terminate daemon and frontend - let _ = Command::new("killall").arg("-q").arg("quickshell").status(); + // Gracefully terminate daemon and agility frontend + for pid in get_agility_quickshell_pids() { + let _ = Command::new("kill") + .arg("-15") + .arg(pid.to_string()) + .status(); + } let _ = Command::new("killall").arg("-q").arg("agilityd").status(); let _ = Command::new("killall") .arg("-q") @@ -430,13 +453,15 @@ async fn handle_status() -> Result<()> { } // Quickshell process check - let qs_pid = get_process_pid("quickshell"); + let qs_pid = get_agility_quickshell_pid(); match qs_pid { Some(pid) => { let rss = get_process_rss_mb(pid); - println!("● Frontend (quickshell): RUNNING (PID: {pid}, Memory: {rss:.1} MB RSS)"); + println!( + "● Frontend (quickshell - agility): RUNNING (PID: {pid}, Memory: {rss:.1} MB RSS)" + ); } - None => println!("○ Frontend (quickshell): STOPPED"), + None => println!("○ Frontend (quickshell - agility): STOPPED"), } // Total memory calculation @@ -1464,6 +1489,31 @@ fn is_command_available(cmd: &str) -> bool { .unwrap_or(false) } +fn get_agility_quickshell_pids() -> Vec { + let mut pids = Vec::new(); + if let Ok(out) = Command::new("pgrep").arg("-a").arg("quickshell").output() { + if out.status.success() { + let s = String::from_utf8_lossy(&out.stdout); + for line in s.lines() { + let parts: Vec<&str> = line.trim().split_whitespace().collect(); + if parts.len() >= 2 { + let cmdline = parts[1..].join(" "); + if cmdline.contains("agility") || cmdline.contains("agility-shell") { + if let Ok(pid) = parts[0].parse::() { + pids.push(pid); + } + } + } + } + } + } + pids +} + +fn get_agility_quickshell_pid() -> Option { + get_agility_quickshell_pids().into_iter().next() +} + fn get_process_pid(proc_name: &str) -> Option { let out = Command::new("pgrep") .arg("-x") @@ -1551,10 +1601,11 @@ fn dispatch_qs_ipc(target: &str, func: &str, args: &[&str]) -> bool { let qml_path = locate_shell_qml(); let mut cmd = Command::new("quickshell"); + cmd.args(["ipc", "-i", "agility-shell"]); if let Some(ref p) = qml_path { cmd.args(["-p", p.to_str().unwrap_or("")]); } - cmd.args(["ipc", "call", target, func]); + cmd.args(["call", target, func]); for a in args { cmd.arg(*a); } @@ -1565,10 +1616,11 @@ fn dispatch_qs_ipc(target: &str, func: &str, args: &[&str]) -> bool { } let mut fallback = Command::new("qs"); + fallback.args(["ipc", "-i", "agility-shell"]); if let Some(ref p) = qml_path { fallback.args(["-p", p.to_str().unwrap_or("")]); } - fallback.args(["ipc", "call", target, func]); + fallback.args(["call", target, func]); for a in args { fallback.arg(*a); } @@ -1785,6 +1837,22 @@ fn expand_user_path(p: &str) -> std::path::PathBuf { Path::new(trimmed).to_path_buf() } +fn get_custom_wallpaper_dir() -> Option { + let home = std::env::var("HOME").ok()?; + let prefs_path = Path::new(&home).join(".cache/quickshell/settings_prefs.json"); + let content = fs::read_to_string(&prefs_path).ok()?; + let val: serde_json::Value = serde_json::from_str(&content).ok()?; + if val.get("wpSourceMode").and_then(|v| v.as_str()) == Some("custom") { + if let Some(folder) = val.get("wpCustomFolderPath").and_then(|v| v.as_str()) { + let expanded = expand_user_path(folder); + if expanded.is_dir() { + return Some(expanded); + } + } + } + None +} + fn resolve_cli_wallpaper(path_str: &str) -> Option { let trimmed = path_str.trim(); if trimmed.is_empty() { @@ -1799,6 +1867,10 @@ fn resolve_cli_wallpaper(path_str: &str) -> Option { let file_name = direct.file_name()?.to_str()?; let mut search_dirs = Vec::new(); + if let Some(custom_dir) = get_custom_wallpaper_dir() { + search_dirs.push(custom_dir); + } + if let Ok(home) = std::env::var("HOME") { search_dirs.push(Path::new(&home).join(".local/share/agility-shell/wallpapers")); search_dirs.push(Path::new(&home).join(".config/agility-shell/wallpapers")); @@ -1823,17 +1895,22 @@ fn resolve_cli_wallpaper(path_str: &str) -> Option { fn list_cli_wallpapers() -> Vec { let mut search_dirs = Vec::new(); - if let Ok(home) = std::env::var("HOME") { - search_dirs.push(Path::new(&home).join(".local/share/agility-shell/wallpapers")); - search_dirs.push(Path::new(&home).join(".config/agility-shell/wallpapers")); - search_dirs.push(Path::new(&home).join("Pictures/Wallpapers")); - search_dirs.push(Path::new(&home).join("Pictures")); - } - if let Ok(data_home) = std::env::var("XDG_DATA_HOME") { - search_dirs.push(Path::new(&data_home).join("agility-shell/wallpapers")); + + if let Some(custom_dir) = get_custom_wallpaper_dir() { + search_dirs.push(custom_dir); + } else { + if let Ok(home) = std::env::var("HOME") { + search_dirs.push(Path::new(&home).join(".local/share/agility-shell/wallpapers")); + search_dirs.push(Path::new(&home).join(".config/agility-shell/wallpapers")); + search_dirs.push(Path::new(&home).join("Pictures/Wallpapers")); + search_dirs.push(Path::new(&home).join("Pictures")); + } + if let Ok(data_home) = std::env::var("XDG_DATA_HOME") { + search_dirs.push(Path::new(&data_home).join("agility-shell/wallpapers")); + } + search_dirs.push(Path::new("/usr/share/agility-shell/wallpapers").to_path_buf()); + search_dirs.push(Path::new("wallpapers").to_path_buf()); } - search_dirs.push(Path::new("/usr/share/agility-shell/wallpapers").to_path_buf()); - search_dirs.push(Path::new("wallpapers").to_path_buf()); let mut found = Vec::new(); let mut seen_names = std::collections::HashSet::new(); @@ -1885,6 +1962,8 @@ async fn handle_wallpaper( action: &str, transition: Option<&str>, duration: Option, + pos: Option<&str>, + skip_backend: bool, json: bool, ) -> Result<()> { let action_lower = action.trim().to_lowercase(); @@ -1986,12 +2065,12 @@ async fn handle_wallpaper( let picked = &walls[idx]; let path_str = picked.to_string_lossy().to_string(); // Apply this chosen wallpaper - apply_cli_wallpaper(&path_str, transition, duration).await?; + apply_cli_wallpaper(&path_str, transition, duration, pos, skip_backend).await?; println!("{path_str}"); } _ => { // Target is a path or filename - apply_cli_wallpaper(action, transition, duration).await?; + apply_cli_wallpaper(action, transition, duration, pos, skip_backend).await?; } } @@ -2002,10 +2081,16 @@ async fn apply_cli_wallpaper( path_str: &str, transition: Option<&str>, duration: Option, + pos: Option<&str>, + skip_backend: bool, ) -> Result<()> { // 1. Try D-Bus SetWallpaper if let Ok(conn) = Connection::session().await { - let t_type = transition.unwrap_or(""); + let t_type = if skip_backend { + "skip" + } else { + transition.unwrap_or("") + }; let dur = duration.unwrap_or(0.0); if let Ok(reply) = conn .call_method( @@ -2031,33 +2116,43 @@ async fn apply_cli_wallpaper( resolve_cli_wallpaper(path_str).context(format!("Wallpaper file not found: {path_str}"))?; let abs_str = resolved.to_string_lossy().to_string(); - // Ensure awww-daemon is running - if is_command_available("awww-daemon") && get_process_pid("awww-daemon").is_none() { - let _ = Command::new("awww-daemon").spawn(); - } - - // Dispatch awww img with ultra-fast bilinear filter and 60fps step - if is_command_available("awww") { - let mut cmd = Command::new("awww"); - let t_type = transition.unwrap_or("grow"); - let dur_str = format!("{:.2}", duration.unwrap_or(0.2)); - cmd.args([ - "img", - &abs_str, - "--resize", - "crop", - "--filter", - "Bilinear", - "--transition-type", - t_type, - "--transition-duration", - &dur_str, - "--transition-step", - "180", - "--transition-fps", - "60", - ]); - let _ = cmd.spawn(); + if !skip_backend { + // Ensure awww-daemon is running + if is_command_available("awww-daemon") && get_process_pid("awww-daemon").is_none() { + let _ = Command::new("awww-daemon").spawn(); + } + + // Dispatch awww img with ultra-fast bilinear filter and 60fps step + if is_command_available("awww") { + let mut cmd = Command::new("awww"); + let t_type = transition.unwrap_or("grow"); + let dur_str = format!("{:.2}", duration.unwrap_or(0.25)); + cmd.args([ + "img", + &abs_str, + "--resize", + "crop", + "--filter", + "Bilinear", + "--transition-type", + t_type, + "--transition-bezier", + ".54,0,.34,.99", + "--transition-duration", + &dur_str, + "--transition-step", + "180", + "--transition-fps", + "60", + ]); + if let Some(p) = pos { + if p.contains(',') { + cmd.arg("--invert-y"); + } + cmd.args(["--transition-pos", p]); + } + let _ = cmd.spawn(); + } } // Write caches diff --git a/quickshell/agility/shell.qml b/quickshell/agility/shell.qml index fc0bd5db..05f7c232 100644 --- a/quickshell/agility/shell.qml +++ b/quickshell/agility/shell.qml @@ -1,3 +1,5 @@ +//@ pragma ShellId agility-shell +//@ pragma AppId agility-shell import QtQuick import Quickshell import Quickshell.Io @@ -135,6 +137,36 @@ ShellRoot { notificationService: globalNotificationService } + Variants { + model: Quickshell.screens + + PanelWindow { + required property var modelData + screen: modelData + + WlrLayershell.layer: WlrLayer.Background + WlrLayershell.keyboardFocus: WlrKeyboardFocus.None + color: "transparent" + focusable: false + visible: SettingsService.settingsLoaded && HyprlandService.wpClicksEnabled + + anchors { + top: true + bottom: true + left: true + right: true + } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton + onDoubleClicked: (mouse) => { + WallpaperManager.cycleNextWallpaper(mouse.x, mouse.y, parent.width, parent.height); + } + } + } + } + Timer { id: startupSoundTimer interval: 300 From 2a43e8d32ac1b02088f5c0408a47ed4966a3aaca Mon Sep 17 00:00:00 2001 From: Chintan Patel <216989679+Chintanpatel24@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:25:31 +0530 Subject: [PATCH 3/3] fix(cli): remove redundant trim before split_whitespace for clippy compliance --- crates/agility-cli/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/agility-cli/src/main.rs b/crates/agility-cli/src/main.rs index 01709792..726eb33d 100644 --- a/crates/agility-cli/src/main.rs +++ b/crates/agility-cli/src/main.rs @@ -1495,7 +1495,7 @@ fn get_agility_quickshell_pids() -> Vec { if out.status.success() { let s = String::from_utf8_lossy(&out.stdout); for line in s.lines() { - let parts: Vec<&str> = line.trim().split_whitespace().collect(); + let parts: Vec<&str> = line.split_whitespace().collect(); if parts.len() >= 2 { let cmdline = parts[1..].join(" "); if cmdline.contains("agility") || cmdline.contains("agility-shell") {