79 lines
2.5 KiB
QML
79 lines
2.5 KiB
QML
pragma Singleton
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
|
|
QtObject {
|
|
id: root
|
|
|
|
// base16 palette, overwritten from ~/.config/nova-shell/theme.json
|
|
property color base00: "#1e1e2e"
|
|
property color base01: "#181825"
|
|
property color base02: "#313244"
|
|
property color base03: "#45475a"
|
|
property color base04: "#585b70"
|
|
property color base05: "#cdd6f4"
|
|
property color base06: "#f5e0dc"
|
|
property color base07: "#b4befe"
|
|
property color base08: "#f38ba8"
|
|
property color base09: "#fab387"
|
|
property color base0A: "#f9e2af"
|
|
property color base0B: "#a6e3a1"
|
|
property color base0C: "#94e2d5"
|
|
property color base0D: "#89b4fa"
|
|
property color base0E: "#cba6f7"
|
|
property color base0F: "#f2cdcd"
|
|
|
|
property string fontFamily: "sans-serif"
|
|
property string iconFontFamily: "Symbols Nerd Font"
|
|
property int fontSize: 12
|
|
property real barOpacity: 0.9
|
|
property int barHeight: 32
|
|
property int barPadding: 8
|
|
property int barSpacing: 12
|
|
property int moduleSpacing: 4
|
|
property int radius: 4
|
|
property int screenRadius: 15
|
|
|
|
property FileView _themeFile: FileView {
|
|
path: (Quickshell.env("XDG_CONFIG_HOME") || (Quickshell.env("HOME") + "/.config")) + "/nova-shell/theme.json"
|
|
watchChanges: true
|
|
onFileChanged: reload()
|
|
onLoaded: root._apply(text())
|
|
}
|
|
|
|
function _apply(raw) {
|
|
let data;
|
|
try {
|
|
data = JSON.parse(raw);
|
|
} catch (e) {
|
|
return;
|
|
}
|
|
const c = data.colors || {};
|
|
for (const k of Object.keys(c)) {
|
|
if (k in root)
|
|
root[k] = c[k];
|
|
}
|
|
if (data.fontFamily)
|
|
root.fontFamily = data.fontFamily;
|
|
if (data.iconFontFamily)
|
|
root.iconFontFamily = data.iconFontFamily;
|
|
if (data.fontSize)
|
|
root.fontSize = data.fontSize;
|
|
if (data.barOpacity !== undefined)
|
|
root.barOpacity = data.barOpacity;
|
|
if (data.barHeight !== undefined)
|
|
root.barHeight = data.barHeight;
|
|
if (data.barPadding !== undefined)
|
|
root.barPadding = data.barPadding;
|
|
if (data.barSpacing !== undefined)
|
|
root.barSpacing = data.barSpacing;
|
|
if (data.moduleSpacing !== undefined)
|
|
root.moduleSpacing = data.moduleSpacing;
|
|
if (data.radius !== undefined)
|
|
root.radius = data.radius;
|
|
if (data.screenRadius !== undefined)
|
|
root.screenRadius = data.screenRadius;
|
|
}
|
|
}
|