Skip to content

feat(wallpaper): add folder-based wallpaper selection and shuffle - #2990

Merged
bbedward merged 7 commits into
duxlabs-dev:masterfrom
greenbugx:feat/wallpaper-folder
Aug 21, 2026
Merged

bbedward merged 7 commits into
duxlabs-dev:masterfrom
greenbugx:feat/wallpaper-folder

Conversation

@greenbugx

Copy link
Copy Markdown
Contributor

Description

Adds a dedicated folder picker in the Settings wallpaper tab, allowing users to explicitly select an entire directory for automatic cycling without needing to manually select a dummy file.

Additionally, introduces a new Shuffle toggle to the Automatic Cycling configuration. When enabled, the background service seamlessly pipes the dynamically queried wallpaper list to shuf instead of sort, ensuring a truly random wallpaper is picked on every cycle while immediately adapting to any external file changes in the directory (e.g. from Nix or sync tools).

Note: Depends on the dank-qml-common FileBrowser folderMode fix submitted in this PR to resolve folder highlighting edge cases.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor / internal cleanup
  • Documentation
  • Other

Related issues

Closes #2833

Screenshots / video

image image
recording.mp4

Checklist

@greenbugx
greenbugx force-pushed the feat/wallpaper-folder branch from f8a6db0 to 83c600a Compare August 5, 2026 15:48

@bbedward bbedward left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged the qml-common change, so you can bump the submodule ref in this PR

@greenbugx
greenbugx force-pushed the feat/wallpaper-folder branch from a767f9a to f298161 Compare August 7, 2026 16:56
@greenbugx
greenbugx requested a review from bbedward August 7, 2026 19:41
folderMode: true
showHiddenFiles: true
onFileSelected: path => {
var folderPath = path.startsWith("file://") ? path.substring(7) : path;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onFileSelected callback already strips the file:// from path, so this can be removed. We also prefer the Paths.strip helper in general where it is needed

onFileSelected: path => {
var folderPath = path.startsWith("file://") ? path.substring(7) : path;
var targetMonitor = SessionData.perMonitorWallpaper ? selectedMonitorName : "";
WallpaperCyclingService.cycleToNextWallpaper(targetMonitor, folderPath + "/dummy.jpg");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add a proper function in WallpaperCyclingService, would make it clearer than using dummy.jpg

function cycleFromFolder(screenName, folderPath) {
    listWallpapers(folderPath, files => applyFirstWallpaper(screenName, files));
}

@greenbugx
greenbugx force-pushed the feat/wallpaper-folder branch from f298161 to 8837a22 Compare August 17, 2026 17:52
@greenbugx

Copy link
Copy Markdown
Contributor Author

@bbedward changes are done, please check again.

@greenbugx
greenbugx force-pushed the feat/wallpaper-folder branch from 8837a22 to 429b178 Compare August 19, 2026 17:58
@bbedward

Copy link
Copy Markdown
Member

/claude review

Comment on lines +194 to +203
process.currentWallpaper = "";
process.goToPrevious = false;
process.running = true;
return;
}

var globalProcess = cyclingProcess;
globalProcess.command = findCommand(folderPath);
globalProcess.targetScreenName = screenName || "";
globalProcess.currentWallpaper = "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing currentWallpaper = "" makes applyCycledWallpaper skip the first image in the folder. With currentPath === "", findIndex returns -1, so currentIndex is coerced to 0 and the non-random branch computes targetIndex = (0 + 1) % length → the second file alphabetically. So selecting a folder with 2+ wallpapers never applies the first one (and with random cycling on, the do/while excludes index 0, so the first image can't be picked on the initial selection either). Only the single-file case works, because 1 % 1 === 0.

Either apply wallpaperList[0] directly for the folder-select path (the applyFirstWallpaper shape suggested earlier), or pass a sentinel that applyCycledWallpaper understands as "start at the first entry" instead of reusing the "next from current" logic.

if (!folderPath)
return;

SessionData.wallpaperCyclingFolderPath = folderPath;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wallpaperCyclingFolderPath is written here (and declared in SessionData.qml / SessionSpec.js) but never read anywhere — no other QML, and buildServerConfig() doesn't send it to the server either. So the "persist folder selection across restarts" goal isn't actually achieved; after a restart cycling still derives the directory from SessionData.wallpaperPath in cycle(). Either consume it (e.g. prefer it over the current wallpaper's dirname in cycle()) or drop the setting so it isn't persisted dead state.


FileBrowserModal {
parentModal: root.parentModal
browserTitle: I18n.tr("Select Wallpaper Folder", "wallpaper folder file browser title")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Select Wallpaper Folder is a new term, but Choose wallpaper folder already exists in quickshell/translations/en.json and is already translated in several locales. CONTRIBUTING asks to reuse existing terms where possible.

Suggested change
browserTitle: I18n.tr("Select Wallpaper Folder", "wallpaper folder file browser title")
browserTitle: I18n.tr("Choose wallpaper folder", "wallpaper folder file browser title")

@claude

claude Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Claude review

Feature works end-to-end, but folder selection skips the first wallpaper and the new persisted setting is never read.

  • Folder select applies the second image, not the first — currentWallpaper = "" makes applyCycledWallpaper fall through to (0+1) % length, quickshell/Services/WallpaperCyclingService.qml:194-203
  • wallpaperCyclingFolderPath is written but never read anywhere, so folder selection is not actually restored across restarts, quickshell/Services/WallpaperCyclingService.qml:187
  • New term Select Wallpaper Folder duplicates the already-translated Choose wallpaper folder, quickshell/Modules/Settings/WallpaperTab.qml:1377

Checked: cycling logic against the files.length < 1 change (single-file folders are fine), the folderMode FileBrowser contract in the pinned dank-qml-common, per-monitor routing, I18n contexts, and that en.json/template.json were not touched. Model: claude-opus-5.

@greenbugx

Copy link
Copy Markdown
Contributor Author

@bbedward

@bbedward

Copy link
Copy Markdown
Member

/claude review

Comment on lines +157 to +162
let wallpaperDir;
if (SessionData.wallpaperCyclingFolderPath) {
wallpaperDir = SessionData.wallpaperCyclingFolderPath;
} else {
wallpaperDir = currentWallpaper.substring(0, currentWallpaper.lastIndexOf('/'));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once wallpaperCyclingFolderPath is set it is never cleared, so it permanently overrides the directory of the actual current wallpaper. Pick folder /A, then pick a single file /B/pic.png via "Select Wallpaper", then hit next: cycle() still lists /A, findIndex("/B/pic.png") is -1 → currentIndex = 0 → applies /A's second file. Neither setWallpaper() nor clearWallpaper() resets the setting and there is no UI to clear it, so the shell can never go back to "cycle within the current wallpaper's folder".

Reset SessionData.wallpaperCyclingFolderPath = "" whenever a wallpaper file is chosen directly (main browser / setWallpaper / clearWallpaper), or only use the stored folder when the current wallpaper is actually inside it.

Comment on lines +192 to +193
SessionData.wallpaperCyclingFolderPath = folderPath;
SessionData.saveSettings();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In per-monitor mode WallpaperTab calls cycleFromFolder(selectedMonitorName, path), but the folder is stored in a single global setting. Choosing a folder for DP-1 therefore also redirects HDMI-A-1: cycleNextForMonitor("HDMI-A-1") → cycle() reads the same wallpaperCyclingFolderPath and lists DP-1's folder. Per-monitor cycling state lives in SessionData.monitorCyclingSettings (see getMonitorCyclingSettings) — store the folder there when screenName is set, and only write the global one for screenName === "".

"intervalSec": s.interval || 300,
"time": s.time || "06:00"
"time": s.time || "06:00",
"folderPath": SessionData.wallpaperCyclingFolderPath || ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is dropped on the wire: the server decodes into wallpaper.ScheduleConfig (core/internal/server/wallpaper/types.go:5), which only has enabled/mode/intervalSec/time, so folderPath is silently discarded. It's also the global value copied into every per-monitor entry, and it isn't sent in global at all. The server only schedules ticks — it never resolves wallpaper files — so nothing needs it; drop the line.

@claude

claude Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Claude review

Earlier findings are fixed; the remaining issues are all about the new global wallpaperCyclingFolderPath being too broad.

  • Folder path is never cleared, so it permanently overrides the current wallpaper's directory — picking a single file from another folder then cycling jumps back into the old folder, quickshell/Services/WallpaperCyclingService.qml:157-162
  • Per-monitor folder selection writes a global setting, so choosing a folder for one monitor redirects cycling on all of them, quickshell/Services/WallpaperCyclingService.qml:192
  • folderPath added to the server config is dropped by wallpaper.ScheduleConfig in Go and is dead, quickshell/Services/WallpaperCyclingService.qml:114

Checked: the first-image fix (isInitialFolderSelect path is correct, single-file folders now work), folderMode wiring through FileBrowserSaveRow → FileBrowserContent → onFileSelected in the pinned submodule, I18n term reuse, and that en.json/template.json were untouched. Model: claude-opus-5.

@greenbugx

Copy link
Copy Markdown
Contributor Author

@bbedward

@bbedward

Copy link
Copy Markdown
Member

/claude review

@claude

claude Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Claude review

No issues found. All three findings from the previous round are addressed.

Checked:

  • wallpaperCyclingFolderPath is now actually read in cycle() (quickshell/Services/WallpaperCyclingService.qml:157-170), and the containment guard (currentWallpaper.startsWith(folderPath + "/")) prevents a stale folder from overriding the current wallpaper's directory.
  • Per-monitor folder is stored per-monitor via SessionData.setMonitorCyclingFolderPath() (quickshell/Common/SessionData.qml:1004), which mirrors the existing setMonitorCyclingInterval/setMonitorCyclingTime shape exactly (screen lookup, model/name key eviction, display-name identifier) and round-trips through _findMonitorValue / getMonitorCyclingSettings.
  • folderPath is no longer sent in buildServerConfig(), so nothing is dropped by Go's wallpaper.ScheduleConfig.
  • Folder path is cleared on every direct wallpaper selection: settings/dash browsers, clear button, and both wallpaper set/setFor IPC handlers.
  • applyCycledWallpaper initial-select path (currentPath === "" → index 0) applies the first image, and single-file folders work with the files.length < 1 guard, for next/prev/random.
  • folderMode + showHiddenFiles exist on FileBrowserModal in the pinned dank-qml-common and emit a plain (non-URL, non-percent-encoded) path via FileBrowserSaveRow.folderSelected → FileBrowserContent.fileSelected; no submodule bump needed.
  • Choose wallpaper folder reuses the existing en.json term (I18n._lookup falls back across contexts, so the new translator context still resolves); en.json/template.json untouched; no Go changes.

Model: claude-opus-5.

@bbedward
bbedward merged commit d22dae1 into duxlabs-dev:master Aug 21, 2026
1 check passed
@greenbugx
greenbugx deleted the feat/wallpaper-folder branch August 22, 2026 14:57
marcusramberg pushed a commit to marcusramberg/DankMaterialShell that referenced this pull request Sep 2, 2026
…xlabs-dev#2990)

* feat(wallpaper): add folder-based wallpaper selection and shuffle

* fix(wallpaper): bump 'dank-qml-common' and handle single-wallpaper folders

* fix(wallpaper): address review feedback for folder selection

* fix(wallpaper): persist folder selection across restarts

* fix(wallpaper): pick first wallpaper on folder select and persist folder path

* fix: resolve wallpaper cycling folder persistence issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wallpaper folders

2 participants