From 16884a19f22e851da6b90553250634cda8c36bce Mon Sep 17 00:00:00 2001 From: Uyanide Date: Wed, 11 Mar 2026 16:03:16 +0100 Subject: [PATCH] qs: add wallpaper cycling functionality --- .../quickshell/Services/IPCService.qml | 4 ++ .../quickshell/Services/SettingsService.qml | 2 + .../quickshell/Services/WallpaperCycle.qml | 56 +++++++++++++++++++ .../quickshell/.config/quickshell/shell.qml | 1 + config/wallpaper/.config/wallreel/config.json | 2 +- config/wallpaper/Pictures/backgrounds | 2 +- memo/lfs.md | 26 ++++----- 7 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 config/quickshell/.config/quickshell/Services/WallpaperCycle.qml diff --git a/config/quickshell/.config/quickshell/Services/IPCService.qml b/config/quickshell/.config/quickshell/Services/IPCService.qml index e3a8cff..50b14d5 100644 --- a/config/quickshell/.config/quickshell/Services/IPCService.qml +++ b/config/quickshell/.config/quickshell/Services/IPCService.qml @@ -34,6 +34,10 @@ Item { BackgroundService.setWallpaper(path); } + function next() { + WallpaperCycle.applyNext(); + } + target: "background" } diff --git a/config/quickshell/.config/quickshell/Services/SettingsService.qml b/config/quickshell/.config/quickshell/Services/SettingsService.qml index 9b44df1..c83ed73 100644 --- a/config/quickshell/.config/quickshell/Services/SettingsService.qml +++ b/config/quickshell/.config/quickshell/Services/SettingsService.qml @@ -13,6 +13,7 @@ Singleton { property alias location: adapter.location property alias backgroundPath: adapter.backgroundPath property alias wifiEnabled: adapter.wifiEnabled + property alias cycleWallpapers: adapter.cycleWallpapers FileView { id: settingFile @@ -34,6 +35,7 @@ Singleton { property string location: "New York" property string backgroundPath: "" property bool wifiEnabled: true + property list cycleWallpapers: [] } } diff --git a/config/quickshell/.config/quickshell/Services/WallpaperCycle.qml b/config/quickshell/.config/quickshell/Services/WallpaperCycle.qml new file mode 100644 index 0000000..ec9dddd --- /dev/null +++ b/config/quickshell/.config/quickshell/Services/WallpaperCycle.qml @@ -0,0 +1,56 @@ +import QtQuick +import Quickshell +import Quickshell.Io +import qs.Utils +pragma Singleton + +Singleton { + id: root + + property int cycleInterval: 900 // in seconds + property var wallpapers: SettingsService.cycleWallpapers + + function applyNext() { + if (root.wallpapers.length === 0) { + Logger.w("WallpaperCycle", "No wallpapers to cycle through, skipping."); + return ; + } + cycleTimer.stop(); + const current = SettingsService.backgroundPath; + let index = -1; + if (current) { + for (let i = 0; i < root.wallpapers.length; i++) { + if (root.wallpapers[i] === current) { + index = i; + break; + } + } + } + if (index === -1) { + Logger.w("WallpaperCycle", "Current wallpaper not found in cycle list, starting from the beginning."); + index = 0; + } else { + index = (index + 1) % root.wallpapers.length; + } + const nextWallpaper = root.wallpapers[index]; + Logger.i("WallpaperCycle", "Cycling to next wallpaper: " + nextWallpaper); + _apply(nextWallpaper); + cycleTimer.start(); + } + + function _apply(path) { + Quickshell.execDetached(["sh", "-c", "wallreel -a '" + path + "'"]); + } + + Timer { + id: cycleTimer + + running: false + repeat: true + interval: root.cycleInterval * 1000 + onTriggered: { + root.applyNext(); + } + } + +} diff --git a/config/quickshell/.config/quickshell/shell.qml b/config/quickshell/.config/quickshell/shell.qml index f8daeee..99ee8ec 100644 --- a/config/quickshell/.config/quickshell/shell.qml +++ b/config/quickshell/.config/quickshell/shell.qml @@ -23,6 +23,7 @@ ShellRoot { Component.onCompleted: { SunsetService; NotesService; + WallpaperCycle; } IPCService { diff --git a/config/wallpaper/.config/wallreel/config.json b/config/wallpaper/.config/wallreel/config.json index 7dbe9d7..0b7d4f6 100644 --- a/config/wallpaper/.config/wallreel/config.json +++ b/config/wallpaper/.config/wallreel/config.json @@ -16,7 +16,7 @@ ] }, "action": { - "onSelected": "qs ipc call background set '{{ path }}'; touch '{{ path }}'; change-colortheme -c '{{ colorHex }}'", + "onSelected": "qs ipc call background set '{{ path }}'; change-colortheme -c '{{ colorHex }}'", "onPreview": "qs ipc call background preview '{{ path }}'; change-colortheme -c '{{ colorHex }}' quickshell niri", "quitOnSelected": true, "saveState": [ diff --git a/config/wallpaper/Pictures/backgrounds b/config/wallpaper/Pictures/backgrounds index d5ec705..387114f 160000 --- a/config/wallpaper/Pictures/backgrounds +++ b/config/wallpaper/Pictures/backgrounds @@ -1 +1 @@ -Subproject commit d5ec7053b7370969e3b518e071e918c5f89b4bdf +Subproject commit 387114f5e47a42c2cf177a60265ba9d1ab6fa0cd diff --git a/memo/lfs.md b/memo/lfs.md index a10b625..1c436c1 100644 --- a/memo/lfs.md +++ b/memo/lfs.md @@ -115,28 +115,28 @@ set -euo pipefail # mount virtual file systems -mkdir -pv $LFS/{dev,proc,sys,run} +mkdir -pv "$LFS"/{dev,proc,sys,run} -mount -v --bind /dev $LFS/dev +mountpoint -q "$LFS"/dev || mount -v --bind /dev "$LFS"/dev -mount -vt devpts devpts -o gid=5,mode=0620 $LFS/dev/pts -mount -vt proc proc $LFS/proc -mount -vt sysfs sysfs $LFS/sys -mount -vt tmpfs tmpfs $LFS/run +mountpoint -q "$LFS"/dev/pts || mount -vt devpts devpts -o gid=5,mode=0620 $LFS/dev/pts +mountpoint -q "$LFS"/proc || mount -vt proc proc "$LFS"/proc +mountpoint -q "$LFS"/sys || mount -vt sysfs sysfs "$LFS"/sys +mountpoint -q "$LFS"/run || mount -vt tmpfs tmpfs "$LFS"/run -if [ -h $LFS/dev/shm ]; then - install -v -d -m 1777 $LFS$(realpath /dev/shm) +if [ -h "$LFS"/dev/shm ]; then + install -v -d -m 1777 "${LFS}$(realpath /dev/shm)" else - mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm + mount -vt tmpfs -o nosuid,nodev tmpfs "$LFS"/dev/shm fi # cleanup (defer) cleanup() { echo "Cleaning up..." - mountpoint -q $LFS/dev/shm && umount $LFS/dev/shm - umount $LFS/dev/pts - umount $LFS/{sys,proc,run,dev} + mountpoint -q "$LFS"/dev/shm && umount "$LFS"/dev/shm || true + umount "$LFS"/dev/pts || true + umount "$LFS"/{sys,proc,run,dev} || true } trap cleanup EXIT INT TERM @@ -239,7 +239,7 @@ chroot "$LFS" /usr/bin/env -i \ NVIDIA 专有驱动的安装指引在 [GLFS 中](https://www.linuxfromscratch.org/glfs/view/stable/shareddeps/drivers-NVIDIA.html)有详细说明. 但其依赖众多, 其中包括很多 BLFS 和 GLFS 中的软件包. 因此不必心急, 可以先按需安装 BLFS 中的其他包, 等到需要 [Mesa](https://www.linuxfromscratch.org/blfs/view/stable-systemd/x/mesa.html) 作为依赖时再去 GLFS 中安装 NVIDIA 驱动, 这将会轻松不少. 关于其对内核配置的影响, 总结出来有以下两点: - - 禁用 nouveau. 除非显卡型号过于老旧, 否则不推荐使用内核中的 nouveau 驱动, 对应配置选项如 `CONFIG_DRM_NOUVEAU` `CONFIG_FB_NVIDIA` 等可留空. [GLFS NVIDIA-590.48.01 页面页脚](https://www.linuxfromscratch.org/glfs/view/stable/shareddeps/NVIDIA.html#ftn.idm139677630432800)有提到 + - 禁用 nouveau. 除非显卡型号过于老旧, 否则不推荐使用内核中的 nouveau 驱动, 对应配置选项如 `CONFIG_DRM_NOUVEAU` `CONFIG_FB_NVIDIA` 等可留空. [GLFS NVIDIA-590.48.01 页面页脚](https://www.linuxfromscratch.org/glfs/view/stable/shareddeps/nvidia.html)有提到 > NVIDIA's kernel modules will fail to compile with TTY support unless a graphics driver is included in the kernel. Nouveau is used here, though alternate graphics drivers may also work.