mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Add screen argument to IPC wallpaper random
* Add argument to specify on which screen to apply a random wallpaper * if `all` is provided, the old behavior is kept: a random wallpaper is applied to all screen.
This commit is contained in:
@@ -42,7 +42,7 @@ NIconButton {
|
||||
PanelService.closeContextMenu(screen);
|
||||
|
||||
if (action === "random-wallpaper") {
|
||||
WallpaperService.setRandomWallpaper();
|
||||
WallpaperService.setRandomWallpaper(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ NIconButtonHot {
|
||||
icon: "wallpaper-selector"
|
||||
tooltipText: I18n.tr("wallpaper.panel.title")
|
||||
onClicked: PanelService.getPanel("wallpaperPanel", screen)?.toggle()
|
||||
onRightClicked: WallpaperService.setRandomWallpaper()
|
||||
onRightClicked: WallpaperService.setRandomWallpaper(null)
|
||||
}
|
||||
|
||||
@@ -405,9 +405,12 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
function random() {
|
||||
function random(screen: string) {
|
||||
if (Settings.data.wallpaper.enabled) {
|
||||
WallpaperService.setRandomWallpaper();
|
||||
if (screen === "all" || screen.trim().length === 0) {
|
||||
screen = undefined;
|
||||
}
|
||||
WallpaperService.setRandomWallpaper(screen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -376,19 +376,29 @@ Singleton {
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
function setRandomWallpaper() {
|
||||
function setRandomWallpaper(screen) {
|
||||
Logger.d("Wallpaper", "setRandomWallpaper");
|
||||
|
||||
if (Settings.data.wallpaper.enableMultiMonitorDirectories) {
|
||||
// Pick a random wallpaper per screen
|
||||
for (var i = 0; i < Quickshell.screens.length; i++) {
|
||||
var screenName = Quickshell.screens[i].name;
|
||||
var wallpaperList = getWallpapersList(screenName);
|
||||
if (screen === undefined) {
|
||||
// Pick a random wallpaper per screen
|
||||
for (var i = 0; i < Quickshell.screens.length; i++) {
|
||||
var screenName = Quickshell.screens[i].name;
|
||||
var wallpaperList = getWallpapersList(screenName);
|
||||
|
||||
if (wallpaperList.length > 0) {
|
||||
var randomIndex = Math.floor(Math.random() * wallpaperList.length);
|
||||
var randomPath = wallpaperList[randomIndex];
|
||||
changeWallpaper(randomPath, screenName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Pick a random wallpaper for the screen argument
|
||||
var wallpaperList = getWallpapersList(screen);
|
||||
if (wallpaperList.length > 0) {
|
||||
var randomIndex = Math.floor(Math.random() * wallpaperList.length);
|
||||
var randomPath = wallpaperList[randomIndex];
|
||||
changeWallpaper(randomPath, screenName);
|
||||
changeWallpaper(randomPath, screen);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -398,7 +408,7 @@ Singleton {
|
||||
if (wallpaperList.length > 0) {
|
||||
var randomIndex = Math.floor(Math.random() * wallpaperList.length);
|
||||
var randomPath = wallpaperList[randomIndex];
|
||||
changeWallpaper(randomPath, undefined);
|
||||
changeWallpaper(randomPath, screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -470,7 +480,7 @@ Singleton {
|
||||
if (mode === "alphabetical") {
|
||||
setAlphabeticalWallpaper();
|
||||
} else {
|
||||
setRandomWallpaper();
|
||||
setRandomWallpaper(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user