Files
menologion/quickshell/services/Theme.qml
T

53 lines
1.5 KiB
QML
Raw Normal View History

2026-09-18 09:17:14 -04:00
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
// Colours, read from a JSON file so the widget follows whatever themes the
// rest of your desktop.
//
// Every key has a default, so the widget is legible with no file at all. Point
// HOROLOGION_COLORS at your own, or drop one at the path below. The shape is
// the flat sixteen-colour kind most theme generators already emit.
Singleton {
id: root
readonly property string path: {
const env = Quickshell.env("HOROLOGION_COLORS");
return env && env !== ""
? env
: Quickshell.env("HOME") + "/.config/horologion/colors.json";
}
property var c: ({})
readonly property color bg: c.bg ?? "#1d2021"
readonly property color surface: c.surface ?? "#282828"
readonly property color overlay: c.overlay ?? "#504945"
readonly property color fg: c.fg ?? "#ebdbb2"
readonly property color fgDim: c.fgDim ?? "#a89984"
readonly property color accent: c.accent ?? "#d3869b"
readonly property color red: c.red ?? "#fb4934"
readonly property color yellow: c.yellow ?? "#fabd2f"
readonly property color green: c.green ?? "#b8bb26"
function reload() { file.reload(); load(); }
function load() {
try {
root.c = JSON.parse(file.text());
} catch (e) {
root.c = ({});
}
}
FileView {
id: file
path: root.path
watchChanges: true
onFileChanged: root.reload()
onLoaded: root.load()
}
}