restructure module config to objects with enable + extra options

This commit is contained in:
Damocles 2026-04-12 17:36:38 +02:00
parent 4109078a91
commit 55ab5bc4e7
9 changed files with 123 additions and 117 deletions

View file

@ -7,27 +7,25 @@ import Quickshell.Io
QtObject {
id: root
property bool workspaces: true
property bool tray: true
property bool windowTitle: true
property bool clock: true
property bool notifications: true
property bool mpris: true
property bool volume: true
property bool bluetooth: true
property bool backlight: true
property bool network: true
property bool powerProfile: true
property bool idleInhibitor: true
property bool weather: true
property bool temperature: true
property bool cpu: true
property bool memory: true
property bool disk: true
property bool battery: true
property bool power: true
property var weatherArgs: ["--nerd"]
property var workspaces: ({ enable: true })
property var tray: ({ enable: true })
property var windowTitle: ({ enable: true })
property var clock: ({ enable: true })
property var notifications: ({ enable: true })
property var mpris: ({ enable: true })
property var volume: ({ enable: true })
property var bluetooth: ({ enable: true })
property var backlight: ({ enable: true, step: 5 })
property var network: ({ enable: true })
property var powerProfile: ({ enable: true })
property var idleInhibitor: ({ enable: true })
property var weather: ({ enable: true, args: ["--nerd"] })
property var temperature: ({ enable: true })
property var cpu: ({ enable: true })
property var memory: ({ enable: true })
property var disk: ({ enable: true })
property var battery: ({ enable: true })
property var power: ({ enable: true })
property FileView _file: FileView {
path: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) + "/nova-shell/modules.json"
@ -44,10 +42,12 @@ QtObject {
return;
}
for (const k of Object.keys(data)) {
if (k in root && typeof root[k] === "boolean")
root[k] = data[k];
if (!(k in root)) continue;
const v = data[k];
if (typeof v === "object" && v !== null)
root[k] = Object.assign({}, root[k], v);
else if (typeof v === "boolean")
root[k] = Object.assign({}, root[k], { enable: v });
}
if (Array.isArray(data.weatherArgs))
root.weatherArgs = data.weatherArgs;
}
}