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

@ -5,7 +5,7 @@ import "." as M
M.BarSection {
id: root
spacing: M.Theme.moduleSpacing
opacity: M.Modules.backlight && percent > 0 ? 1 : 0
opacity: M.Modules.backlight.enable && percent > 0 ? 1 : 0
visible: opacity > 0
tooltip: "Brightness: " + root.percent + "%"
@ -22,7 +22,8 @@ M.BarSection {
}
function adjust(delta) {
adjProc.cmd = delta > 0 ? "light -A 5" : "light -U 5";
const step = M.Modules.backlight.step || 5;
adjProc.cmd = delta > 0 ? "light -A " + step : "light -U " + step;
adjProc.running = true;
}

View file

@ -53,8 +53,8 @@ PanelWindow {
M.BarGroup {
borderColor: M.Theme.base0D
M.Clock { visible: M.Modules.clock }
M.Notifications { visible: M.Modules.notifications }
M.Clock { visible: M.Modules.clock.enable }
M.Notifications { visible: M.Modules.notifications.enable }
}
}
@ -67,17 +67,17 @@ PanelWindow {
M.BarGroup {
borderColor: M.Theme.base0D
M.Workspaces { bar: bar; visible: M.Modules.workspaces }
M.Workspaces { bar: bar; visible: M.Modules.workspaces.enable }
}
M.BarGroup {
borderColor: M.Theme.base0D
M.Tray { bar: bar; visible: M.Modules.tray }
M.Tray { bar: bar; visible: M.Modules.tray.enable }
}
M.BarGroup {
borderColor: M.Theme.base0D
M.WindowTitle {
Layout.maximumWidth: 400
visible: M.Modules.windowTitle
visible: M.Modules.windowTitle.enable
}
}
Item { Layout.fillWidth: true }
@ -96,13 +96,13 @@ PanelWindow {
M.BarGroup {
borderColor: M.Theme.base0E
M.Mpris {}
M.Volume { visible: M.Modules.volume }
M.Volume { visible: M.Modules.volume.enable }
}
// Connectivity
M.BarGroup {
borderColor: M.Theme.base0D
M.Network { visible: M.Modules.network }
M.Network { visible: M.Modules.network.enable }
M.Bluetooth {}
}
@ -110,25 +110,25 @@ PanelWindow {
M.BarGroup {
borderColor: M.Theme.base0A
M.Backlight {}
M.PowerProfile { visible: M.Modules.powerProfile }
M.IdleInhibitor { visible: M.Modules.idleInhibitor }
M.PowerProfile { visible: M.Modules.powerProfile.enable }
M.IdleInhibitor { visible: M.Modules.idleInhibitor.enable }
}
// Stats
M.BarGroup {
borderColor: M.Theme.base08
M.Cpu { visible: M.Modules.cpu }
M.Memory { visible: M.Modules.memory }
M.Temperature { visible: M.Modules.temperature }
M.Weather { visible: M.Modules.weather }
M.Disk { visible: M.Modules.disk }
M.Cpu { visible: M.Modules.cpu.enable }
M.Memory { visible: M.Modules.memory.enable }
M.Temperature { visible: M.Modules.temperature.enable }
M.Weather { visible: M.Modules.weather.enable }
M.Disk { visible: M.Modules.disk.enable }
}
// Power
M.BarGroup {
borderColor: M.Theme.base08
M.Battery {}
M.Power { bar: bar; visible: M.Modules.power }
M.Power { bar: bar; visible: M.Modules.power.enable }
}
}
}

View file

@ -6,7 +6,7 @@ import "." as M
M.BarSection {
id: root
spacing: M.Theme.moduleSpacing
opacity: M.Modules.battery && (UPower.displayDevice?.isLaptopBattery ?? false) ? 1 : 0
opacity: M.Modules.battery.enable && (UPower.displayDevice?.isLaptopBattery ?? false) ? 1 : 0
visible: opacity > 0
tooltip: {
const state = root.charging ? "Charging" : "Discharging";

View file

@ -5,7 +5,7 @@ import "." as M
M.BarSection {
id: root
spacing: M.Theme.moduleSpacing
opacity: M.Modules.bluetooth && root.state !== "unavailable" ? 1 : 0
opacity: M.Modules.bluetooth.enable && root.state !== "unavailable" ? 1 : 0
visible: opacity > 0
tooltip: {
if (root.state === "off")

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;
}
}

View file

@ -5,7 +5,7 @@ import "." as M
M.BarSection {
id: root
spacing: M.Theme.moduleSpacing
opacity: M.Modules.mpris && player !== null ? 1 : 0
opacity: M.Modules.mpris.enable && player !== null ? 1 : 0
visible: opacity > 0
tooltip: {
const p = root.player;

View file

@ -12,7 +12,7 @@ M.BarSection {
Process {
id: proc
running: true
command: ["wttrbar"].concat(M.Modules.weatherArgs)
command: ["wttrbar"].concat(M.Modules.weather.args)
stdout: StdioCollector {
onStreamFinished: {
try {