Skip to content
Open
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
38 changes: 38 additions & 0 deletions quickshell/Common/SessionData.qml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Singleton {
property var includedTransitions: availableWallpaperTransitions.filter(t => t !== "none")

property bool wallpaperCyclingEnabled: false
property bool wallpaperCyclingRandom: false
property string wallpaperCyclingMode: "interval"
property int wallpaperCyclingInterval: 300
property string wallpaperCyclingTime: "06:00"
Expand Down Expand Up @@ -649,6 +650,11 @@ Singleton {
saveSettings();
}

function setWallpaperCyclingRandom(random) {
wallpaperCyclingRandom = random;
saveSettings();
}

function setWallpaperCyclingMode(mode) {
wallpaperCyclingMode = mode;
saveSettings();
Expand Down Expand Up @@ -695,6 +701,37 @@ Singleton {
saveSettings();
}

function setMonitorCyclingRandom(screenName, random) {
var screen = null;
var screens = Quickshell.screens;
for (var i = 0; i < screens.length; i++) {
if (screens[i].name === screenName) {
screen = screens[i];
break;
}
}

if (!screen) {
log.warn("Screen not found");
return;
}

var identifier = typeof SettingsData !== "undefined" ? SettingsData.getScreenDisplayName(screen) : screen.name;

var newSettings = {};
for (var key in monitorCyclingSettings) {
var isThisScreen = key === screen.name || (screen.model && key === screen.model);
if (!isThisScreen) {
newSettings[key] = monitorCyclingSettings[key];
}
}

newSettings[identifier] = getMonitorCyclingSettings(screenName);
newSettings[identifier].random = random;
monitorCyclingSettings = newSettings;
saveSettings();
}

function setMonitorCyclingMode(screenName, mode) {
var screen = null;
var screens = Quickshell.screens;
Expand Down Expand Up @@ -1376,6 +1413,7 @@ Singleton {
function getMonitorCyclingSettings(screenName) {
var defaults = {
"enabled": false,
"random": false,
"mode": "interval",
"interval": 300,
"time": "06:00"
Expand Down
1 change: 1 addition & 0 deletions quickshell/Common/settings/SessionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var SPEC = {
includedTransitions: { def: ["fade", "wipe", "disc", "stripes", "iris bloom", "pixelate", "portal"] },

wallpaperCyclingEnabled: { def: false },
wallpaperCyclingRandom: { def: false },
wallpaperCyclingMode: { def: "interval" },
wallpaperCyclingInterval: { def: 300 },
wallpaperCyclingTime: { def: "06:00" },
Expand Down
27 changes: 27 additions & 0 deletions quickshell/Modules/Settings/WallpaperTab.qml
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,33 @@ Item {
}
}

SettingsToggleRow {
id: randomToggle
tab: "wallpaper"
tags: ["cycling", "automatic", "random", "shuffle"]
settingKey: "wallpaperCyclingRandom"
width: parent.width - Theme.spacingM * 2
text: I18n.tr("Random Order")
description: I18n.tr("Select a random wallpaper instead of cycling in alphabetical order")
checked: SessionData.perMonitorWallpaper ? SessionData.getMonitorCyclingSettings(selectedMonitorName).random : SessionData.wallpaperCyclingRandom
onToggled: toggled => {
if (SessionData.perMonitorWallpaper) {
SessionData.setMonitorCyclingRandom(selectedMonitorName, toggled);
} else {
SessionData.setWallpaperCyclingRandom(toggled);
}
}

Connections {
target: root
function onSelectedMonitorNameChanged() {
randomToggle.checked = Qt.binding(() => {
return SessionData.perMonitorWallpaper ? SessionData.getMonitorCyclingSettings(selectedMonitorName).random : SessionData.wallpaperCyclingRandom;
});
}
}
}

SettingsDropdownRow {
id: intervalDropdown
property var intervalOptions: [I18n.tr("5 seconds", "wallpaper interval"), I18n.tr("10 seconds", "wallpaper interval"), I18n.tr("15 seconds", "wallpaper interval"), I18n.tr("20 seconds", "wallpaper interval"), I18n.tr("25 seconds", "wallpaper interval"), I18n.tr("30 seconds", "wallpaper interval"), I18n.tr("35 seconds", "wallpaper interval"), I18n.tr("40 seconds", "wallpaper interval"), I18n.tr("45 seconds", "wallpaper interval"), I18n.tr("50 seconds", "wallpaper interval"), I18n.tr("55 seconds", "wallpaper interval"), I18n.tr("1 minute", "wallpaper interval"), I18n.tr("5 minutes", "wallpaper interval"), I18n.tr("15 minutes", "wallpaper interval"), I18n.tr("30 minutes", "wallpaper interval"), I18n.tr("1 hour", "wallpaper interval"), I18n.tr("1 hour 30 minutes", "wallpaper interval"), I18n.tr("2 hours", "wallpaper interval"), I18n.tr("3 hours", "wallpaper interval"), I18n.tr("4 hours", "wallpaper interval"), I18n.tr("6 hours", "wallpaper interval"), I18n.tr("8 hours", "wallpaper interval"), I18n.tr("12 hours", "wallpaper interval")]
Expand Down
23 changes: 20 additions & 3 deletions quickshell/Services/WallpaperCyclingService.qml
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,28 @@ Singleton {
if (currentIndex === -1)
currentIndex = 0;

let isRandom = false;
if (targetScreenName) {
isRandom = !!SessionData.getMonitorCyclingSettings(targetScreenName).random;
} else {
isRandom = !!SessionData.wallpaperCyclingRandom;
}

let targetIndex;
if (goToPrevious) {
targetIndex = currentIndex === 0 ? wallpaperList.length - 1 : currentIndex - 1;
if (isRandom) {
if (wallpaperList.length > 1) {
do {
targetIndex = Math.floor(Math.random() * wallpaperList.length);
} while (targetIndex === currentIndex);
} else {
targetIndex = 0;
}
} else {
targetIndex = (currentIndex + 1) % wallpaperList.length;
if (goToPrevious) {
targetIndex = currentIndex === 0 ? wallpaperList.length - 1 : currentIndex - 1;
} else {
targetIndex = (currentIndex + 1) % wallpaperList.length;
}
}
const targetWallpaper = wallpaperList[targetIndex];
if (!targetWallpaper || targetWallpaper === currentPath)
Expand Down
27 changes: 27 additions & 0 deletions quickshell/translations/settings_search_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,33 @@
],
"icon": "palette"
},
{
"section": "wallpaperCyclingRandom",
"label": "Random Order",
"tabIndex": 0,
"category": "Personalization",
"keywords": [
"alphabetical",
"appearance",
"automatic",
"background",
"bg",
"custom",
"customize",
"cycling",
"desktop",
"image",
"order",
"personal",
"personalization",
"picture",
"random",
"select",
"shuffle",
"wallpaper"
],
"description": "Select a random wallpaper instead of cycling in alphabetical order"
},
{
"section": "wallpaperTransition",
"label": "Transition Effect",
Expand Down
Loading