diff --git a/config/Theme.qml b/config/Theme.qml index 91fbf0b..afc58e4 100644 --- a/config/Theme.qml +++ b/config/Theme.qml @@ -1,7 +1,9 @@ pragma Singleton +pragma ComponentBehavior: Bound import QtQuick import Quickshell +import Quickshell.Io Singleton { id: root @@ -10,30 +12,68 @@ Singleton { source: "../assets/lucide.woff" } property string fontFamily: "JetBrainsMono Nerd Font" - property Palette palette: Palette {} + property var palette: theme.palette - component Palette: QtObject { - id: palette + property list themes: [] + onThemesChanged: { + if (!themes.includes(currentTheme)) { + currentTheme = "dark"; + } + } + property string currentTheme: "dark" - property color primary: "#1fb854" - property color primarycontent: "#000000" - property color secondary: "#1eb88e" - property color secondarycontent: "#000c07" - property color accent: "#1fb8ab" - property color accentcontent: "#010c0b" - property color neutral: "#19362d" - property color neutralcontent: "#cdd3d1" - property color base100: "#1b1717" - property color base200: "#161212" - property color base300: "#110d0d" - property color basecontent: "#cac9c9" - property color info: "#00b5ff" - property color infocontent: "#000000" - property color success: "#00a96e" - property color successcontent: "#000000" - property color warning: "#ffbe00" - property color warningcontent: "#000000" - property color error: "#ff5861" - property color errorcontent: "#000000" + Process { + running: true + command: ["bash", "-c", `inotifywait -m -r ~/.config/lux -e modify,move,create,delete | while read dir action; do ls -m "$dir"; done`] + stderr: StdioCollector { + onStreamFinished: console.log(`line read: ${this.text}`) + } + stdout: SplitParser { + splitMarker: "\n" + onRead: data => { + const themes = data.split(", ").filter(item => item.endsWith(".json")).map(item => item.replace(".json", "")); + if (themes.length == 0) { + return; + } + root.themes = themes; + } + } + } + + FileView { + id: jsonFile + path: `${Paths.config}/themes/${root.currentTheme}.json` + watchChanges: true + onFileChanged: reload() + + // when changes are made to properties in the adapter, save them + onAdapterUpdated: writeAdapter() + + JsonAdapter { + id: theme + + property JsonObject palette: JsonObject { + property color primary: "#605dff" + property color primarycontent: "#edf1fe" + property color secondary: "#f43098" + property color secondarycontent: "#f9e4f0" + property color accent: "#00d3bb" + property color accentcontent: "#084d49" + property color neutral: "#09090b" + property color neutralcontent: "#e4e4e7" + property color base100: "#1d232a" + property color base200: "#191e24" + property color base300: "#15191e" + property color basecontent: "#ecf9ff" + property color info: "#00bafe" + property color infocontent: "#042e49" + property color success: "#00d390" + property color successcontent: "#004c39" + property color warning: "#fcb700" + property color warningcontent: "#793205" + property color error: "#ff627d" + property color errorcontent: "#4d0218" + } + } } }