diff --git a/crates/agility-cli/src/main.rs b/crates/agility-cli/src/main.rs index 9698e8a1..726eb33d 100644 --- a/crates/agility-cli/src/main.rs +++ b/crates/agility-cli/src/main.rs @@ -1601,7 +1601,7 @@ fn dispatch_qs_ipc(target: &str, func: &str, args: &[&str]) -> bool { let qml_path = locate_shell_qml(); let mut cmd = Command::new("quickshell"); - cmd.arg("ipc"); + cmd.args(["ipc", "-i", "agility-shell"]); if let Some(ref p) = qml_path { cmd.args(["-p", p.to_str().unwrap_or("")]); } @@ -1616,7 +1616,7 @@ fn dispatch_qs_ipc(target: &str, func: &str, args: &[&str]) -> bool { } let mut fallback = Command::new("qs"); - fallback.arg("ipc"); + fallback.args(["ipc", "-i", "agility-shell"]); if let Some(ref p) = qml_path { fallback.args(["-p", p.to_str().unwrap_or("")]); } @@ -2126,7 +2126,7 @@ async fn apply_cli_wallpaper( 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)); + let dur_str = format!("{:.2}", duration.unwrap_or(0.25)); cmd.args([ "img", &abs_str, @@ -2136,6 +2136,8 @@ async fn apply_cli_wallpaper( "Bilinear", "--transition-type", t_type, + "--transition-bezier", + ".54,0,.34,.99", "--transition-duration", &dur_str, "--transition-step", 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/quickshell/agility/shell.qml b/quickshell/agility/shell.qml index 6cf851c6..48bc04b0 100644 --- a/quickshell/agility/shell.qml +++ b/quickshell/agility/shell.qml @@ -183,7 +183,6 @@ ShellRoot { OsdPill { id: osdPillWindow } - Timer { id: startupSoundTimer interval: 300 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