fix: default modules to disabled, enable non-configured ones after json load
This commit is contained in:
parent
631e14cdc9
commit
9257941fe0
1 changed files with 41 additions and 26 deletions
|
|
@ -8,90 +8,97 @@ QtObject {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var workspaces: ({
|
property var workspaces: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var tray: ({
|
property var tray: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var windowTitle: ({
|
property var windowTitle: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var clock: ({
|
property var clock: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var notifications: ({
|
property var notifications: ({
|
||||||
enable: true,
|
enable: false,
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
maxPopups: 4,
|
maxPopups: 4,
|
||||||
maxVisible: 10,
|
maxVisible: 10,
|
||||||
maxHistory: -1
|
maxHistory: -1
|
||||||
})
|
})
|
||||||
property var mpris: ({
|
property var mpris: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var volume: ({
|
property var volume: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var bluetooth: ({
|
property var bluetooth: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var backlight: ({
|
property var backlight: ({
|
||||||
enable: true,
|
enable: false,
|
||||||
step: 5
|
step: 5
|
||||||
})
|
})
|
||||||
property var network: ({
|
property var network: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var powerProfile: ({
|
property var powerProfile: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var idleInhibitor: ({
|
property var idleInhibitor: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var weather: ({
|
property var weather: ({
|
||||||
enable: true,
|
enable: false,
|
||||||
args: ["--nerd"],
|
args: ["--nerd"],
|
||||||
interval: 3600000
|
interval: 3600000
|
||||||
})
|
})
|
||||||
property var temperature: ({
|
property var temperature: ({
|
||||||
enable: true,
|
enable: false,
|
||||||
warm: 80,
|
warm: 80,
|
||||||
hot: 90
|
hot: 90
|
||||||
})
|
})
|
||||||
property var cpu: ({
|
property var cpu: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var memory: ({
|
property var memory: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var disk: ({
|
property var disk: ({
|
||||||
enable: true,
|
enable: false,
|
||||||
interval: 30000
|
interval: 30000
|
||||||
})
|
})
|
||||||
property var battery: ({
|
property var battery: ({
|
||||||
enable: true,
|
enable: false,
|
||||||
warning: 25,
|
warning: 25,
|
||||||
critical: 15
|
critical: 15
|
||||||
})
|
})
|
||||||
property var privacy: ({
|
property var privacy: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var screenCorners: ({
|
property var screenCorners: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var power: ({
|
property var power: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var backgroundOverlay: ({
|
property var backgroundOverlay: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var overviewBackdrop: ({
|
property var overviewBackdrop: ({
|
||||||
enable: true
|
enable: false
|
||||||
})
|
})
|
||||||
property var statsDaemon: ({
|
property var statsDaemon: ({
|
||||||
interval: -1
|
interval: -1
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// All module keys that have an enable flag — used to default-enable anything
|
||||||
|
// not explicitly mentioned in modules.json
|
||||||
|
readonly property var _moduleKeys: ["workspaces", "tray", "windowTitle", "clock", "notifications", "mpris", "volume", "bluetooth", "backlight", "network", "powerProfile", "idleInhibitor", "weather", "temperature", "cpu", "memory", "disk", "battery", "privacy", "screenCorners", "power", "backgroundOverlay", "overviewBackdrop"]
|
||||||
|
|
||||||
|
// Fallback: if modules.json doesn't exist, enable everything
|
||||||
|
Component.onCompleted: _apply("{}")
|
||||||
|
|
||||||
property FileView _file: FileView {
|
property FileView _file: FileView {
|
||||||
path: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) + "/nova-shell/modules.json"
|
path: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) + "/nova-shell/modules.json"
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
|
|
@ -100,12 +107,20 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _apply(raw) {
|
function _apply(raw) {
|
||||||
let data;
|
let data = {};
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(raw);
|
data = JSON.parse(raw);
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
return;
|
|
||||||
|
// Enable all modules that aren't explicitly mentioned in the JSON
|
||||||
|
for (const k of _moduleKeys) {
|
||||||
|
if (!(k in data))
|
||||||
|
root[k] = Object.assign({}, root[k], {
|
||||||
|
enable: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply JSON overrides
|
||||||
for (const k of Object.keys(data)) {
|
for (const k of Object.keys(data)) {
|
||||||
if (!(k in root))
|
if (!(k in root))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue