67 lines
2.9 KiB
QML
67 lines
2.9 KiB
QML
pragma Singleton
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
|
|
QtObject {
|
|
id: root
|
|
|
|
// Defaults. User config overrides any of these.
|
|
property string fontFamily: "JetBrainsMono Nerd Font Propo"
|
|
property int fontSize: 16
|
|
property string giphyApiKey: ""
|
|
property int panelWidth: 720
|
|
property int panelHeight: 520
|
|
property int padding: 5
|
|
property int spacing: 5
|
|
property int radius: 10
|
|
property string backgroundColor: ""
|
|
property string foregroundColor: ""
|
|
property string idleColor: ""
|
|
property string accentColor: ""
|
|
property string overlayStrongColor: ""
|
|
property string overlayWeakColor: ""
|
|
property string borderColor: ""
|
|
|
|
property bool loaded: false
|
|
|
|
function _apply(obj) {
|
|
if (typeof obj.fontFamily === "string" && obj.fontFamily.length > 0) fontFamily = obj.fontFamily;
|
|
if (typeof obj.fontSize === "number" && obj.fontSize > 0) fontSize = obj.fontSize;
|
|
if (typeof obj.giphyApiKey === "string") giphyApiKey = obj.giphyApiKey;
|
|
if (typeof obj.panelWidth === "number" && obj.panelWidth > 0) panelWidth = obj.panelWidth;
|
|
if (typeof obj.panelHeight === "number" && obj.panelHeight > 0) panelHeight = obj.panelHeight;
|
|
if (typeof obj.padding === "number" && obj.padding > 0) padding = obj.padding;
|
|
if (typeof obj.spacing === "number" && obj.spacing > 0) spacing = obj.spacing;
|
|
if (typeof obj.radius === "number" && obj.radius >= 0) radius = obj.radius;
|
|
|
|
const colors = obj.colors || {};
|
|
if (typeof colors.background === "string" && colors.background.length > 0) backgroundColor = colors.background;
|
|
if (typeof colors.foreground === "string" && colors.foreground.length > 0) foregroundColor = colors.foreground;
|
|
if (typeof colors.idle === "string" && colors.idle.length > 0) idleColor = colors.idle;
|
|
if (typeof colors.accent === "string" && colors.accent.length > 0) accentColor = colors.accent;
|
|
if (typeof colors.overlayStrong === "string" && colors.overlayStrong.length > 0) overlayStrongColor = colors.overlayStrong;
|
|
if (typeof colors.overlayWeak === "string" && colors.overlayWeak.length > 0) overlayWeakColor = colors.overlayWeak;
|
|
if (typeof colors.border === "string" && colors.border.length > 0) borderColor = colors.border;
|
|
}
|
|
|
|
property Process _loader: Process {
|
|
running: true
|
|
command: ["sh", "-c", "cat \"${XDG_CONFIG_HOME:-$HOME/.config}/omni-launcher/config.json\" 2>/dev/null"]
|
|
stdout: StdioCollector {
|
|
onStreamFinished: {
|
|
const text = (this.text || "").trim();
|
|
if (text.length > 0) {
|
|
try {
|
|
root._apply(JSON.parse(text));
|
|
} catch (e) {
|
|
console.log("omni-launcher: config.json parse error:", e);
|
|
}
|
|
}
|
|
root.loaded = true;
|
|
}
|
|
}
|
|
}
|
|
}
|