Add wallpaper mode controls
This commit is contained in:
@@ -368,6 +368,55 @@ Singleton {
|
||||
return root.applyPolicy(policy, true, false);
|
||||
}
|
||||
|
||||
function setMode(mode: string): bool {
|
||||
if (!["single", "slideshow", "per-monitor"].includes(mode))
|
||||
return false;
|
||||
const policy = root.currentPolicy();
|
||||
policy.mode = mode;
|
||||
if (mode === "slideshow") {
|
||||
const collection = WallpaperPolicy.validCollection(
|
||||
policy.collection, root.candidates([]));
|
||||
if (!collection.includes(policy.slideshowPath))
|
||||
policy.slideshowPath = collection[0] || policy.globalPath;
|
||||
}
|
||||
return root.applyPolicy(policy, true, false);
|
||||
}
|
||||
|
||||
function setAssignment(output: string, path: string): bool {
|
||||
if (!root.outputNames().includes(output)
|
||||
|| !WallpaperPolicy.validPath(path, root.candidates([])))
|
||||
return false;
|
||||
const policy = root.currentPolicy();
|
||||
policy.mode = "per-monitor";
|
||||
policy.assignments = Object.assign({}, policy.assignments);
|
||||
policy.assignments[output] = path;
|
||||
return root.applyPolicy(policy, true, false);
|
||||
}
|
||||
|
||||
function toggleSlideshowPath(path: string): bool {
|
||||
if (!WallpaperPolicy.validPath(path, root.candidates([])))
|
||||
return false;
|
||||
const policy = root.currentPolicy();
|
||||
const collection = WallpaperPolicy.validCollection(policy.collection, root.candidates([]));
|
||||
policy.collection = collection.includes(path)
|
||||
? collection.filter(candidate => candidate !== path)
|
||||
: collection.concat([path]);
|
||||
policy.mode = "slideshow";
|
||||
if (!policy.collection.includes(policy.slideshowPath))
|
||||
policy.slideshowPath = policy.collection[0] || policy.globalPath;
|
||||
return root.applyPolicy(policy, true, false);
|
||||
}
|
||||
|
||||
function setIntervalMinutes(minutes: int): bool {
|
||||
const value = PreferenceSchema.coerce("wallpaperIntervalMinutes", minutes);
|
||||
return value !== undefined
|
||||
&& DesktopPreferences.set("wallpaperIntervalMinutes", value);
|
||||
}
|
||||
|
||||
function setShuffle(enabled: bool): bool {
|
||||
return DesktopPreferences.set("wallpaperShuffle", enabled === true);
|
||||
}
|
||||
|
||||
// Compatibility boundary used by backup/reset and the existing picker.
|
||||
function set(path: string): bool {
|
||||
return root.setSingle(path);
|
||||
|
||||
Reference in New Issue
Block a user