This commit is contained in:
LemmyCook 2025-08-29 09:55:47 -04:00
parent e79c163dd9
commit 861e207fb6
9 changed files with 59 additions and 82 deletions

View file

@ -90,14 +90,9 @@ Singleton {
}
onLoaded: function () {
Qt.callLater(function () {
// Some stuff like wallpaper setup and settings validation should just be executed once on startup
// And not on every reload
// Some stuff like settings validation should just be executed once on startup and not on every reload
if (!isLoaded) {
Logger.log("Settings", "JSON completed loading")
// if (adapter.wallpaper.current !== "") {
// Logger.log("Settings", "Set current wallpaper", adapter.wallpaper.current)
// WallpaperService.setCurrentWallpaper(adapter.wallpaper.current, true)
// }
// Validate monitor configurations, only once
// if none of the configured monitors exist, clear the lists

View file

@ -4,17 +4,18 @@ import Quickshell.Wayland
import qs.Commons
import qs.Services
Loader {
active: true
Variants {
model: Quickshell.screens
sourceComponent: Variants {
model: Quickshell.screens
delegate: Loader {
delegate: PanelWindow {
required property ShellScreen modelData
property string wallpaperSource: WallpaperService.getWallpaper(modelData.name)
required property ShellScreen modelData
property string wallpaperSource: WallpaperService.getWallpaper(modelData.name)
active: wallpaperSource !== ""
sourceComponent: PanelWindow {
visible: wallpaperSource !== ""
color: Color.transparent
screen: modelData
WlrLayershell.layer: WlrLayer.Background
@ -28,15 +29,10 @@ Loader {
left: true
}
margins {
top: 0
}
Image {
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
source: wallpaperSource
visible: wallpaperSource !== ""
cache: true
smooth: true
mipmap: false

View file

@ -6,23 +6,20 @@ import qs.Commons
import qs.Services
import qs.Widgets
Loader {
active: CompositorService.isNiri
Variants {
model: Quickshell.screens
Component.onCompleted: {
if (CompositorService.isNiri) {
Logger.log("Overview", "Loading Overview component for Niri")
}
}
delegate: Loader {
required property ShellScreen modelData
property string wallpaperSource: WallpaperService.getWallpaper(modelData.name)
sourceComponent: Variants {
model: Quickshell.screens
active: CompositorService.isNiri && wallpaperSource !== ""
delegate: PanelWindow {
required property ShellScreen modelData
property string wallpaperSource: WallpaperService.getWallpaper(modelData.name)
sourceComponent: PanelWindow {
Component.onCompleted: {
Logger.log("Overview", "Loading Overview component for Niri on", modelData.name)
}
visible: wallpaperSource !== ""
color: Color.transparent
screen: modelData
WlrLayershell.layer: WlrLayer.Background
@ -38,19 +35,15 @@ Loader {
Image {
id: bgImage
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
source: wallpaperSource
cache: true
smooth: true
mipmap: false
visible: wallpaperSource !== ""
}
MultiEffect {
id: overviewBgBlur
anchors.fill: parent
source: bgImage
blurEnabled: true

View file

@ -93,7 +93,7 @@ Loader {
id: lockBgImage
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
source: WallpaperService.currentWallpaper !== "" ? WallpaperService.currentWallpaper : ""
source: WallpaperService.getWallpaper(screen.name)
cache: true
smooth: true
mipmap: false

View file

@ -23,10 +23,9 @@ ColumnLayout {
Layout.fillWidth: true
Layout.preferredHeight: 140 * scaling
radius: Style.radiusM * scaling
color: Color.mPrimary
color: Color.mSecondary
NImageRounded {
id: currentWallpaperImage
anchors.fill: parent
anchors.margins: Style.marginXS * scaling
imagePath: WallpaperService.getWallpaper(screen.name)
@ -113,7 +112,7 @@ ColumnLayout {
id: wallpaperItem
property string wallpaperPath: modelData
property bool isSelected: wallpaperPath === WallpaperService.currentWallpaper
property bool isSelected: wallpaperPath === WallpaperService.getWallpaper(screen.name)
width: wallpaperGridView.itemSize
height: Math.floor(wallpaperGridView.itemSize * 0.67)

View file

@ -146,16 +146,7 @@ ColumnLayout {
spacing: Style.marginS * scaling
// Factorized presets data
property var intervalPresets: [
5 * 60,
10 * 60,
15 * 60,
30 * 60,
45 * 60,
60 * 60,
90 * 60,
120 * 60,
]
property var intervalPresets: [5 * 60, 10 * 60, 15 * 60, 30 * 60, 45 * 60, 60 * 60, 90 * 60, 120 * 60]
// Whether current interval equals one of the presets
property bool isCurrentPreset: {
@ -237,7 +228,7 @@ ColumnLayout {
property int seconds: 0
property string label: ""
property bool selected: false
signal clicked()
signal clicked
radius: height * 0.5
color: selected ? Color.mPrimary : Color.mSurfaceVariant
@ -266,4 +257,4 @@ ColumnLayout {
Layout.topMargin: Style.marginXL * scaling
Layout.bottomMargin: Style.marginXL * scaling
}
}
}

View file

@ -22,6 +22,8 @@ Singleton {
// Ensure cache dir exists
Quickshell.execDetached(["mkdir", "-p", Settings.cacheDir])
// TODO: fix matugen
var content = buildConfigToml()
var mode = Settings.data.colorSchemes.darkMode ? "dark" : "light"
var wp = WallpaperService.currentWallpaper.replace(/'/g, "'\\''")

View file

@ -11,10 +11,6 @@ Singleton {
Component.onCompleted: {
Logger.log("Wallpaper", "Service started")
listWallpapers()
// Wallpaper is set when the settings are loaded.
// Don't start random wallpaper during initialization
}
readonly property ListModel transitionsModel: ListModel {
@ -33,9 +29,9 @@ Singleton {
Connections {
target: Settings.data.wallpaper
onDirectoryChanged: WallpaperService.listWallpapers()
onRandomEnabledChanged: WallpaperService.toggleRandomWallpaper()
onRandomIntervalChanged: WallpaperService.restartRandomWallpaperTimer()
function onDirectoryChanged() { console.log("ondirchanged") ; root.listWallpapers() }
function onRandomEnabledChanged() { root.toggleRandomWallpaper() }
function onRandomIntervalSecChanged() { root.restartRandomWallpaperTimer() }
}
// -------------------------------------------------------------------
@ -87,7 +83,7 @@ Singleton {
function getWallpaper(screenName) {
// Logger.log("Wallpaper", "getWallpaper on", screenName)
var monitor = geMonitorDefinition(screenName)
if (monitor !== undefined) {
if ((monitor !== undefined) && (monitor["wallpaper"] !== undefined)) {
return monitor["wallpaper"]
}
return ""
@ -95,8 +91,9 @@ Singleton {
// -------------------------------------------------------------------
function changeWallpaper(screenName, path) {
Logger.log("Changing wallpaper")
if (screenName !== undefined) {
setCurrentWallpaper(screenName, path, false)
setCurrentWallpaper(screenName, path)
} else {
for (var i = 0; i < Quickshell.screens.length; i++) {
setCurrentWallpaper(Quickshell.screens[i].name, path, false)
@ -105,7 +102,11 @@ Singleton {
}
// -------------------------------------------------------------------
function setCurrentWallpaper(screenName, path, isInitial) {
function setCurrentWallpaper(screenName, path) {
if (path === "" || path === undefined) {
return
}
if (screenName === undefined) {
Logger.warn("Wallpaper", "setCurrentWallpaper", "no screen specified")
return
@ -113,50 +114,51 @@ Singleton {
Logger.log("Wallpaper", "setCurrentWallpaper on", screenName, ": ", path)
var wallpaperChanged = false
var monitor = geMonitorDefinition(screenName)
if (monitor !== undefined) {
wallpaperChanged = (monitor["wallpaper"] !== path)
monitor["wallpaper"] = path
} else {
wallpaperChanged = true
Settings.data.wallpaper.monitors.push({
"name": screenName,
"directory": Settings.data.wallpaper.directory,
"wallpaper": path
})
})
}
// // Only regenerate colors if the wallpaper actually changed
// var wallpaperChanged = currentWallpaper !== path
// currentWallpaper = path
// if (!isInitial) {
// Settings.data.wallpaper.current = path
// }
// Restart the random wallpaper timer
if (randomWallpaperTimer.running) {
randomWallpaperTimer.restart()
}
// Only notify ColorScheme service if the wallpaper actually changed
// if (wallpaperChanged) {
// ColorSchemeService.changedWallpaper()
// }
// Notify ColorScheme service if the wallpaper actually changed
if (wallpaperChanged) {
ColorSchemeService.changedWallpaper()
}
}
// -------------------------------------------------------------------
function setRandomWallpaper() {
var randomIndex = Math.floor(Math.random() * wallpaperList.length)
var randomPath = wallpaperList[randomIndex]
if (!randomPath) {
return
Logger.log("Wallpaper", "setRandomWallpaper");
for (var i = 0; i < Quickshell.screens.length; i++) {
var screenName = Quickshell.screens[i].name
// TODO one list per monitor
var randomIndex = Math.floor(Math.random() * wallpaperList.length)
var randomPath = wallpaperList[randomIndex]
setCurrentWallpaper(screenName, randomPath)
}
setCurrentWallpaper(randomPath, false)
}
// -------------------------------------------------------------------
function toggleRandomWallpaper() {
if (Settings.data.wallpaper.isRandom && !randomWallpaperTimer.running) {
Logger.log("Wallpaper", "toggleRandomWallpaper")
if (Settings.data.wallpaper.randomEnabled && !randomWallpaperTimer.running) {
randomWallpaperTimer.start()
setRandomWallpaper()
} else if (!Settings.data.randomWallpaper && randomWallpaperTimer.running) {
} else if (!Settings.data.wallpaper.randomEnabled && randomWallpaperTimer.running) {
randomWallpaperTimer.stop()
}
}

View file

@ -47,7 +47,6 @@
libnotify
matugen
networkmanager
swww
wl-clipboard
];