add random wallpaper keybind

This commit is contained in:
end-4
2025-09-21 20:21:34 +02:00
parent 7bbd1d2d52
commit b90cf14228
6 changed files with 29 additions and 10 deletions
+1
View File
@@ -50,6 +50,7 @@ bindl = Alt ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle # [hidd
bindl = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle # [hidden] bindl = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle # [hidden]
bindld = Super+Alt,M, Toggle mic, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle # [hidden] bindld = Super+Alt,M, Toggle mic, exec, wpctl set-mute @DEFAULT_SOURCE@ toggle # [hidden]
bindd = Ctrl+Super, T, Toggle wallpaper selector, global, quickshell:wallpaperSelectorToggle # Wallpaper selector bindd = Ctrl+Super, T, Toggle wallpaper selector, global, quickshell:wallpaperSelectorToggle # Wallpaper selector
bindd = Ctrl+Super+Alt, T, Select random wallpaper, global, quickshell:wallpaperSelectorRandom # Random wallpaper
bindd = Ctrl+Super, T, Change wallpaper, exec, qs -c $qsConfig ipc call TEST_ALIVE || ~/.config/quickshell/$qsConfig/scripts/colors/switchwall.sh # [hidden] Change wallpaper (fallback) bindd = Ctrl+Super, T, Change wallpaper, exec, qs -c $qsConfig ipc call TEST_ALIVE || ~/.config/quickshell/$qsConfig/scripts/colors/switchwall.sh # [hidden] Change wallpaper (fallback)
bind = Ctrl+Super, R, exec, killall ags agsv1 gjs ydotool qs quickshell; qs -c $qsConfig & # Restart widgets bind = Ctrl+Super, R, exec, killall ags agsv1 gjs ydotool qs quickshell; qs -c $qsConfig & # Restart widgets
@@ -263,12 +263,7 @@ Variants {
property real effectiveValueY: Math.max(0, Math.min(1, valueY)) property real effectiveValueY: Math.max(0, Math.min(1, valueY))
x: -(bgRoot.movableXSpace) - (effectiveValueX - 0.5) * 2 * bgRoot.movableXSpace x: -(bgRoot.movableXSpace) - (effectiveValueX - 0.5) * 2 * bgRoot.movableXSpace
y: -(bgRoot.movableYSpace) - (effectiveValueY - 0.5) * 2 * bgRoot.movableYSpace y: -(bgRoot.movableYSpace) - (effectiveValueY - 0.5) * 2 * bgRoot.movableYSpace
source: { source: bgRoot.wallpaperSafetyTriggered ? "" : bgRoot.wallpaperPath
print("-----------------")
print("Safety triggered:", bgRoot.wallpaperSafetyTriggered);
print("Wallpaper path:", bgRoot.wallpaperPath);
return bgRoot.wallpaperSafetyTriggered ? "" : bgRoot.wallpaperPath
}
fillMode: Image.PreserveAspectCrop fillMode: Image.PreserveAspectCrop
Behavior on x { Behavior on x {
NumberAnimation { NumberAnimation {
@@ -71,11 +71,25 @@ Scope {
function toggle(): void { function toggle(): void {
root.toggleWallpaperSelector(); root.toggleWallpaperSelector();
} }
function random(): void {
Wallpapers.randomFromCurrentFolder();
}
} }
GlobalShortcut { GlobalShortcut {
name: "wallpaperSelectorToggle" name: "wallpaperSelectorToggle"
description: "Toggle wallpaper selector" description: "Toggle wallpaper selector"
onPressed: root.toggleWallpaperSelector(); onPressed: {
root.toggleWallpaperSelector();
}
}
GlobalShortcut {
name: "wallpaperSelectorRandom"
description: "Select random wallpaper in current folder"
onPressed: {
Wallpapers.randomFromCurrentFolder();
}
} }
} }
@@ -341,9 +341,7 @@ MouseArea {
ToolbarButton { ToolbarButton {
implicitWidth: height implicitWidth: height
onClicked: { onClicked: {
const randomIndex = Math.floor(Math.random() * Wallpapers.folderModel.count); Wallpapers.randomFromCurrentFolder();
const filePath = Wallpapers.folderModel.get(randomIndex, "filePath");
root.selectWallpaperPath(filePath);
} }
contentItem: MaterialSymbol { contentItem: MaterialSymbol {
anchors.centerIn: parent anchors.centerIn: parent
@@ -33,6 +33,8 @@ Singleton {
signal thumbnailGenerated(directory: string) signal thumbnailGenerated(directory: string)
signal thumbnailGeneratedFile(filePath: string) signal thumbnailGeneratedFile(filePath: string)
function load () {} // For forcing initialization
// Executions // Executions
Process { Process {
id: applyProc id: applyProc
@@ -77,6 +79,14 @@ Singleton {
selectProc.select(filePath, darkMode); selectProc.select(filePath, darkMode);
} }
function randomFromCurrentFolder(darkMode = Appearance.m3colors.darkmode) {
if (folderModel.count === 0) return;
const randomIndex = Math.floor(Math.random() * folderModel.count);
const filePath = folderModel.get(randomIndex, "filePath");
print("Randomly selected wallpaper:", filePath);
root.select(filePath, darkMode);
}
Process { Process {
id: validateDirProc id: validateDirProc
property string nicePath: "" property string nicePath: ""
+1
View File
@@ -61,6 +61,7 @@ ShellRoot {
FirstRunExperience.load() FirstRunExperience.load()
ConflictKiller.load() ConflictKiller.load()
Cliphist.refresh() Cliphist.refresh()
Wallpapers.load()
} }
LazyLoader { active: enableBar && Config.ready && !Config.options.bar.vertical; component: Bar {} } LazyLoader { active: enableBar && Config.ready && !Config.options.bar.vertical; component: Bar {} }