Compare commits
2 commits
16e5059c7a
...
c53f0c2c41
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c53f0c2c41 | ||
|
|
a12b36c188 |
2 changed files with 110 additions and 23 deletions
47
config/Paths.qml
Normal file
47
config/Paths.qml
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import Quickshell
|
||||||
|
import Qt.labs.platform
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
readonly property url home: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
|
||||||
|
readonly property url pictures: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]
|
||||||
|
|
||||||
|
readonly property url data: `${StandardPaths.standardLocations(StandardPaths.GenericDataLocation)[0]}/lux`
|
||||||
|
readonly property url state: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/lux`
|
||||||
|
readonly property url cache: `${StandardPaths.standardLocations(StandardPaths.GenericCacheLocation)[0]}/lux`
|
||||||
|
readonly property url config: `${StandardPaths.standardLocations(StandardPaths.GenericConfigLocation)[0]}/lux`
|
||||||
|
|
||||||
|
readonly property url imagecache: `${cache}/imagecache`
|
||||||
|
|
||||||
|
function stringify(path: url): string {
|
||||||
|
let str = path.toString();
|
||||||
|
if (str.startsWith("root:/"))
|
||||||
|
str = `file://${Quickshell.shellDir}/${str.slice(6)}`;
|
||||||
|
else if (str.startsWith("/"))
|
||||||
|
str = `file://${str}`;
|
||||||
|
return new URL(str).pathname;
|
||||||
|
}
|
||||||
|
|
||||||
|
function expandTilde(path: string): string {
|
||||||
|
return strip(path.replace("~", stringify(root.home)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function shortenHome(path: string): string {
|
||||||
|
return path.replace(strip(root.home), "~");
|
||||||
|
}
|
||||||
|
|
||||||
|
function strip(path: url): string {
|
||||||
|
return stringify(path).replace("file://", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function mkdir(path: url): void {
|
||||||
|
Quickshell.execDetached(["mkdir", "-p", strip(path)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function copy(from: url, to: url): void {
|
||||||
|
Quickshell.execDetached(["cp", strip(from), strip(to)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
@ -10,30 +12,68 @@ Singleton {
|
||||||
source: "../assets/lucide.woff"
|
source: "../assets/lucide.woff"
|
||||||
}
|
}
|
||||||
property string fontFamily: "JetBrainsMono Nerd Font"
|
property string fontFamily: "JetBrainsMono Nerd Font"
|
||||||
property Palette palette: Palette {}
|
property var palette: theme.palette
|
||||||
|
|
||||||
component Palette: QtObject {
|
property list<string> themes: []
|
||||||
id: palette
|
onThemesChanged: {
|
||||||
|
if (!themes.includes(currentTheme)) {
|
||||||
property color primary: "#1fb854"
|
currentTheme = "dark";
|
||||||
property color primarycontent: "#000000"
|
}
|
||||||
property color secondary: "#1eb88e"
|
}
|
||||||
property color secondarycontent: "#000c07"
|
property string currentTheme: "dark"
|
||||||
property color accent: "#1fb8ab"
|
|
||||||
property color accentcontent: "#010c0b"
|
Process {
|
||||||
property color neutral: "#19362d"
|
running: true
|
||||||
property color neutralcontent: "#cdd3d1"
|
command: ["bash", "-c", `inotifywait -m -r ~/.config/lux -e modify,move,create,delete | while read dir action; do ls -m "$dir"; done`]
|
||||||
property color base100: "#1b1717"
|
stderr: StdioCollector {
|
||||||
property color base200: "#161212"
|
onStreamFinished: console.log(`line read: ${this.text}`)
|
||||||
property color base300: "#110d0d"
|
}
|
||||||
property color basecontent: "#cac9c9"
|
stdout: SplitParser {
|
||||||
property color info: "#00b5ff"
|
splitMarker: "\n"
|
||||||
property color infocontent: "#000000"
|
onRead: data => {
|
||||||
property color success: "#00a96e"
|
const themes = data.split(", ").filter(item => item.endsWith(".json")).map(item => item.replace(".json", ""));
|
||||||
property color successcontent: "#000000"
|
if (themes.length == 0) {
|
||||||
property color warning: "#ffbe00"
|
return;
|
||||||
property color warningcontent: "#000000"
|
}
|
||||||
property color error: "#ff5861"
|
root.themes = themes;
|
||||||
property color errorcontent: "#000000"
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue