Compare commits

..

2 commits

Author SHA1 Message Date
Benjamin Palko
c53f0c2c41 migrate themes to config dir 2025-09-05 12:12:11 -04:00
Benjamin Palko
a12b36c188 paths 2025-09-04 20:01:36 -04:00
2 changed files with 110 additions and 23 deletions

47
config/Paths.qml Normal file
View 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)]);
}
}

View file

@ -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<string> 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"
}
}
}
}