Skip to content
Merged
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
8 changes: 5 additions & 3 deletions crates/agility-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("")]);
}
Expand All @@ -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("")]);
}
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand Down
51 changes: 40 additions & 11 deletions crates/agilityd/src/modules/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ pub fn expand_tilde(path_str: &str) -> PathBuf {
PathBuf::from(trimmed)
}

fn get_custom_wallpaper_dir() -> Option<PathBuf> {
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<PathBuf> {
let trimmed = path_str.trim();
Expand All @@ -54,6 +70,10 @@ pub fn resolve_wallpaper_path(path_str: &str) -> Option<PathBuf> {
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"));
Expand All @@ -79,17 +99,22 @@ pub fn resolve_wallpaper_path(path_str: &str) -> Option<PathBuf> {
/// Discover all available wallpaper image files across candidate directories.
pub fn list_all_wallpapers() -> Vec<PathBuf> {
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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions quickshell/agility/Core/Services/HyprlandService.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions quickshell/agility/Core/Services/SettingsService.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
138 changes: 121 additions & 17 deletions quickshell/agility/Core/Services/WallpaperManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -39,41 +55,89 @@ 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) {
HyprlandService.wpAutoShuffle = false;
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
}
Expand All @@ -87,6 +151,7 @@ QtObject {

Component.onCompleted: {
wallpaperLoader.running = true;
reloadWallpaperList();
}

shuffleTimer: Timer {
Expand All @@ -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) {
Expand Down
Loading
Loading