Files
lucid/HyprConfig.qml
T
Sn3aky c0ebc5c3bc Shell: the tray, Lucid's own pointer, the clock engine, network drives and the bar's content size
- Tray: both looks rebuilt in Material You, every app in a slot of its own or
  three stacked with a count; a click opens the tray, each app a row with its
  menu opening in place
- Pointer: Bibata Modern's shapes drawn from source in the palette's colours,
  fading with it, the tilt card, and the shell drawing the pointer itself in drags
- Clock's engine in the shell (Alarms, ClockLink): alarms ring with the app
  closed and always post Snooze and Stop
- Lumen: network drives (Connect to server, shares, Nearby); Lens: videos
- Bar: Content size, notch edges as quarter ellipses up to 64 px, frosted and lit
  on hover; fixes across the dock, desktop, widgets, LucidShot and Settings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 12:57:29 +01:00

863 lines
29 KiB
QML

import QtQuick
import Quickshell
import Quickshell.Hyprland
import Quickshell.Io
pragma Singleton
// the Hyprland options Settings > Windows and Input change: kept in Prefs.hyprOptions,
// rendered into lucid-settings.lua for modules/settings.lua, and read back
// from Hyprland so a page shows what is really in force
Singleton {
id: root
readonly property string hyprDir: Quickshell.env("HOME") + "/.config/hypr"
readonly property string dataPath: root.hyprDir + "/lucid-settings.lua"
readonly property string modulePath: root.hyprDir + "/modules/settings.lua"
readonly property string statusPath: (Quickshell.env("XDG_RUNTIME_DIR") || "/tmp") + "/lucid-settings-status.json"
property bool moduleInstalled: false
property bool moduleProbed: false
// every option a page shows, read back in one hyprctl call
readonly property var keys: ["general.gaps_in", "general.gaps_out", "general.border_size", "general.col.active_border", "general.col.inactive_border", "decoration.rounding", "decoration.rounding_power", "decoration.shadow.enabled", "decoration.shadow.range", "decoration.shadow.render_power", "decoration.dim_inactive", "decoration.dim_strength", "general.layout", "dwindle.split_width_multiplier", "dwindle.force_split", "dwindle.default_split_ratio", "dwindle.preserve_split", "master.orientation", "master.mfact", "master.new_status", "master.new_on_top", "scrolling.column_width", "scrolling.fullscreen_on_one_column", "input.follow_mouse", "misc.focus_on_activate", "cursor.no_warps", "cursor.warp_on_change_workspace", "general.resize_on_border", "general.extend_border_grab_area", "general.snap.enabled", "general.snap.window_gap", "general.snap.monitor_gap", "cursor.hide_on_key_press", "cursor.inactive_timeout", "animations.enabled", "input.kb_layout", "input.kb_variant", "input.kb_options", "input.repeat_rate", "input.repeat_delay", "input.numlock_by_default", "input.sensitivity", "input.accel_profile", "input.natural_scroll", "input.scroll_factor", "input.left_handed", "input.touchpad.tap-to-click", "input.touchpad.natural_scroll", "input.touchpad.scroll_factor", "input.touchpad.disable_while_typing", "input.touchpad.clickfinger_behavior", "input.touchpad.tap-and-drag", "input.touchpad.middle_button_emulation", "gestures.workspace_swipe_distance", "gestures.workspace_swipe_invert", "gestures.workspace_swipe_cancel_ratio", "gestures.workspace_swipe_min_speed_to_force", "gestures.workspace_swipe_forever", "gestures.workspace_swipe_create_new", "plugin.dynamic_cursors.mode", "plugin.dynamic_cursors.tilt.limit", "plugin.dynamic_cursors.tilt.full", "plugin.dynamic_cursors.tilt.window", "plugin.dynamic_cursors.tilt.activation", "plugin.dynamic_cursors.shake.enabled", "plugin.dynamic_cursors.shake.base", "plugin.dynamic_cursors.shake.threshold", "plugin.dynamic_cursors.shake.timeout"]
// not Hyprland options but choices Lucid turns into some
readonly property var borderModes: [{
"key": "none",
"label": "None"
}, {
"key": "accent",
"label": "Accent"
}, {
"key": "gradient",
"label": "Gradient"
}]
// Hyprland as it is now, key -> value
property var live: ({})
// Hyprland has been read at least once, so a missing option means missing
property bool liveRead: false
// hypr-dynamic-cursors, the plugin that tilts the pointer, is loaded: its
// options only exist while it is
readonly property bool cursorPlugin: root.live["plugin.dynamic_cursors.mode"] !== undefined
// the script install.sh puts the plugin together with, for this Hyprland
readonly property string pluginScript: root.hyprDir + "/scripts/cursor-plugin.sh"
property bool pluginScriptFound: false
property bool pluginBuilding: false
property string pluginError: ""
function buildCursorPlugin() {
if (pluginProc.running || !root.pluginScriptFound)
return ;
root.pluginError = "";
root.pluginBuilding = true;
pluginProc.running = true;
}
// written by modules/settings.lua: which options your config overrides
property var status: ({})
// what Settings set, key -> value
readonly property var mine: {
let m = {};
try {
m = JSON.parse(Prefs.hyprOptions || "{}");
} catch (e) {
m = {};
}
return m && typeof m === "object" && !Array.isArray(m) ? m : {};
}
// what hyprland.lua requires after modules.settings, [{ name, text }], for
// naming the file that overrides an option
property var laterFiles: []
// options whose value Lucid works out, such as border colours from the palette
function derived() {
const out = {};
for (const k of ["lucid.border", "lucid.inactive_border"]) {
const t = root.targetOf(k, root.mine[k]);
if (t.value !== undefined)
out[t.option] = t.value;
}
return out;
}
// the option a key stands for and the value it gives it; a choice such as
// lucid.border becomes a border colour worked out from the palette
function targetOf(key, v) {
if (key === "lucid.border") {
let c;
if (v === "none")
c = "rgba(00000000)";
else if (v === "accent")
c = root.rgba(Theme.cPrimary, 1);
else if (v === "gradient")
c = {
"colors": [root.rgba(Theme.cPrimary, 1), root.rgba(Theme.cTertiary, 1), root.rgba(Theme.cSecondary, 1)],
"angle": 45
};
return {
"option": "general.col.active_border",
"value": c
};
}
if (key === "lucid.inactive_border")
return {
"option": "general.col.inactive_border",
"value": v === "none" ? "rgba(00000000)" : (v === "faint" ? root.rgba(Theme.cOutlineVariant, 1) : undefined)
};
if (key.indexOf("lucid.") === 0)
return {
"option": "",
"value": undefined
};
return {
"option": key,
"value": v
};
}
// a value the way modules/settings.lua reports your config's own:
// colours as "aarrggbb,…@angle"
function plainOf(option, v) {
if (option.indexOf(".col.") === -1)
return v;
const argb = (c) => {
const m = /^rgba\(([0-9a-f]{6})([0-9a-f]{2})\)$/i.exec(String(c).trim());
return m ? (m[2] + m[1]).toLowerCase() : String(c).toLowerCase().replace(/^0x/, "");
};
if (v && typeof v === "object" && Array.isArray(v.colors))
return v.colors.map(argb).join(",") + "@" + Math.round(Number(v.angle) || 0);
return argb(v) + "@0";
}
// whether a value is the one your config gives the option anyway
function sameAsBase(option, v) {
const b = (root.status.base || {})[option];
if (option === "" || v === undefined || b === undefined || b === null || root.isOverridden(option))
return false;
const p = root.plainOf(option, v);
if (typeof p === "number" && typeof b === "number")
return Math.abs(p - b) < 0.0001;
return p === b;
}
// Lucid's own switches have no config value behind them, so their default is known here
readonly property var choiceDefaults: ({
"lucid.solo": false,
"lucid.cursor_tilt": true,
"lucid.cursor_tilt_apps": true
})
// a value that changes nothing, so Settings need not keep it
function isDefault(key, v) {
if (root.choiceDefaults[key] !== undefined)
return root.choiceDefaults[key] === v;
const t = root.targetOf(key, v);
return root.sameAsBase(t.option, t.value);
}
// a pinned window's border, from the palette like the others: off, accent,
// tertiary or a gradient between the two
readonly property var pinModes: [{
"key": "off",
"label": "Off"
}, {
"key": "accent",
"label": "Accent"
}, {
"key": "tertiary",
"label": "Tertiary"
}, {
"key": "gradient",
"label": "Gradient"
}]
readonly property var pinColours: {
const m = Prefs.pinBorder;
if (m === "accent")
return [Theme.cPrimary];
if (m === "tertiary")
return [Theme.cTertiary];
if (m === "gradient")
return [Theme.cTertiary, Theme.cPrimary];
return [];
}
// never thinner than 2 px, so it shows even with borders turned off
readonly property int pinBorderSize: Math.max(2, Math.round(root.num("general.border_size", 2)))
// what goes to Hyprland: the options set as they are, the choices worked out
readonly property var wanted: {
const out = {};
for (const k in root.mine) {
if (k.indexOf("lucid.") !== 0)
out[k] = root.mine[k];
}
return Object.assign(out, root.derived());
}
// a border colour as a list of colours: "rgba(rrggbbaa)", { colors, angle } or Hyprland's "aarrggbb … 45deg"
function coloursOf(v) {
const out = [];
const add = (s) => {
let m = /^rgba?\(([0-9a-f]{6})([0-9a-f]{2})?\)$/i.exec(String(s).trim());
if (m) {
out.push(Qt.color("#" + (m[2] || "ff") + m[1]));
return ;
}
m = /^(?:0x)?([0-9a-f]{8})$/i.exec(String(s).trim());
if (m)
out.push(Qt.color("#" + m[1]));
};
if (v && typeof v === "object" && Array.isArray(v.colors))
v.colors.forEach(add);
else if (typeof v === "string")
v.split(/\s+/).forEach(add);
return out.length > 0 ? out : [Qt.color("transparent")];
}
function rgba(c, alpha) {
const hex = (x) => {
return ("0" + Math.round(Math.max(0, Math.min(1, x)) * 255).toString(16)).slice(-2);
};
return "rgba(" + hex(c.r) + hex(c.g) + hex(c.b) + hex(alpha) + ")";
}
function luaStr(s) {
return "\"" + String(s).replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n") + "\"";
}
function luaValue(v) {
if (typeof v === "boolean")
return v ? "true" : "false";
if (typeof v === "number")
return isFinite(v) ? String(Math.round(v * 10000) / 10000) : "0";
if (Array.isArray(v))
return "{ " + v.map(root.luaValue).join(", ") + " }";
if (v && typeof v === "object")
return "{ " + Object.keys(v).sort().map((k) => {
return k + " = " + root.luaValue(v[k]);
}).join(", ") + " }";
return root.luaStr(v);
}
readonly property string rendered: {
const w = root.wanted;
let out = "-- written by Lucid Settings > Windows and Input, and rewritten on every change there\n";
out += "return {\n";
// rules rather than options: a window alone on its workspace goes edge to edge
if (root.mine["lucid.solo"] === true)
out += " solo = true,\n";
// the pointers that lean as they move, named in modules/plugins.lua, and
// whether those of apps that draw their own lean with them
if (root.mine["lucid.cursor_tilt"] !== undefined)
out += " cursor_tilt = " + (root.mine["lucid.cursor_tilt"] === true ? "true" : "false") + ",\n";
if (root.mine["lucid.cursor_tilt_apps"] !== undefined)
out += " cursor_tilt_apps = " + (root.mine["lucid.cursor_tilt_apps"] === true ? "true" : "false") + ",\n";
// one colour for every pinned window, in focus or not; a gradient only
// on the focused one, as its own rule: given in one rule, Hyprland
// keeps the out-of-focus colour but never draws it
if (root.pinColours.length > 0) {
const cs = root.pinColours.map((c) => {
return root.rgba(c, 1);
});
out += " pinned = { border = " + root.luaStr(cs[0] + " " + cs[0]) + (cs.length > 1 ? ", focused = " + root.luaStr(cs.join(" ") + " 45deg") : "") + ", size = " + root.pinBorderSize + " },\n";
}
out += " options = {\n";
for (const k of Object.keys(w).sort())
out += " [" + root.luaStr(k) + "] = " + root.luaValue(w[k]) + ",\n";
out += " },\n}\n";
return out;
}
// options the cursor plugin reads once per config load, so a change to one
// takes a reload rather than a live apply
readonly property var reloadKeys: ["plugin.dynamic_cursors.tilt.activation"]
// the size shake to find grows to: the plugin loads its large copy of the
// theme again after it changes, which has to go through cursortheme.py's lock
readonly property var nudgeKeys: ["plugin.dynamic_cursors.shake.base"]
property var _pending: null
// Hyprland takes the file, then the shell's windows ask for their pointer
// again: the cursor plugin only applies its settings when the shape changes
function applySaved(reload, restoring, nudge) {
if (applyProc.running) {
const p = root._pending || {
"reload": false,
"restoring": [],
"nudge": false
};
root._pending = {
"reload": p.reload || reload,
"restoring": p.restoring.concat(restoring),
"nudge": p.nudge || nudge
};
return ;
}
const restore = restoring.length > 0 ? "LucidSettings.restore({ " + restoring.map(root.luaStr).join(", ") + " }) " : "";
if (reload)
applyProc.command = ["bash", "-c", "hyprctl reload >/dev/null; python3 \"$0\" settle >/dev/null", Pointer.helper];
else
applyProc.command = ["bash", "-c", "hyprctl eval \"$1\" >/dev/null" + (nudge ? "; python3 \"$0\" nudge >/dev/null" : ""), Pointer.helper, "if LucidSettings then " + restore + "LucidSettings.apply(true) end"];
applyProc.running = true;
}
function lineOf(text, key) {
const m = new RegExp("^\\s*\\[\"" + key.replace(/\./g, "\\.") + "\"\\]\\s*=\\s*(.*)$", "m").exec(text || "");
return m ? m[1] : "";
}
function keysIn(text) {
const out = [];
const re = /^\s*\["([^"]+)"\]\s*=/gm;
let m;
while ((m = re.exec(text || "")) !== null) out.push(m[1])
return out;
}
// --- what pages ask
function isMine(key) {
if (root.mine[key] !== undefined)
return true;
return root.derived()[key] !== undefined;
}
function isOverridden(key) {
return (root.status.overridden || []).indexOf(key) !== -1;
}
function failedText(key) {
const f = (root.status.failed || {})[key];
return f ? "Hyprland did not take this: " + f + "." : "";
}
// the whole words an option's name is made of, bar its section
function words(key) {
return key.split(".").slice(1).join(".").split(/[.:]/);
}
function overrideText(key) {
const names = [];
for (const f of root.laterFiles) {
const text = f.text;
if (text === "" || names.indexOf(f.name) !== -1)
continue;
const found = root.words(key).every((w) => {
return new RegExp("(^|[^A-Za-z0-9_])" + w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "([^A-Za-z0-9_]|$)").test(text);
});
if (found)
names.push(f.name === "hyprland-gui.lua" ? "HyprMod (hyprland-gui.lua)" : f.name);
}
const who = names.length > 0 ? names.join(" and ") : "Something in your Hyprland config after Lucid";
return who + " sets this too, and your own config wins over Settings. Take it out there to change it here.";
}
// a value from Settings until the file is on disk, Hyprland's after
function value(key) {
const d = root.wanted[key];
if (d !== undefined && !root.isOverridden(key))
return d;
return root.live[key];
}
// gaps come back as "t r b l"; the first one stands for all
function num(key, fallback) {
const v = root.value(key);
if (typeof v === "number")
return v;
if (typeof v === "boolean")
return v ? 1 : 0;
const n = parseFloat(String(v === undefined ? "" : v).trim().split(/\s+/)[0]);
return isNaN(n) ? fallback : n;
}
function bool(key, fallback) {
const v = root.value(key);
if (typeof v === "boolean")
return v;
if (typeof v === "number")
return v !== 0;
return fallback;
}
function choice(key) {
return root.mine[key] !== undefined ? root.mine[key] : "";
}
// the border mode chosen, or the one your config's own colour matches
function borderMode() {
const c = root.choice("lucid.border");
const v = root.live["general.col.active_border"];
if (c !== "" || v === undefined)
return c;
const key = (x) => {
return root.coloursOf(x).map((q) => {
return q.a === 0 ? "clear" : root.rgba(q, q.a);
}).join(" ");
};
const now = key(v);
const m = root.borderModes.find((b) => {
return key(root.targetOf("lucid.border", b.key).value) === now;
});
return m ? m.key : "";
}
// putting an option back to what your config gives it hands it back
function set(key, v) {
if (root.isDefault(key, v)) {
root.resetKeys([key]);
return ;
}
const m = Object.assign({}, root.mine);
m[key] = v;
Prefs.hyprOptions = JSON.stringify(m);
}
// several at once, so the file is written once and they land together;
// all of them back at your config's values hands them all back
function setMany(values) {
const keys = Object.keys(values);
if (keys.every((k) => {
return root.isDefault(k, values[k]);
})) {
root.resetKeys(keys);
return ;
}
Prefs.hyprOptions = JSON.stringify(Object.assign({}, root.mine, values));
}
// --- keyboard
signal layoutPickerRequested(var taken)
// kb_layout and kb_variant as pairs; the variants line up with the layouts
function layoutList() {
const layouts = String(root.value("input.kb_layout") || "us").split(",");
const variants = String(root.value("input.kb_variant") || "").split(",");
const out = [];
for (let i = 0; i < layouts.length; i++) {
const l = layouts[i].trim();
if (l !== "")
out.push({
"layout": l,
"variant": (variants[i] || "").trim()
});
}
return out;
}
function setLayouts(list) {
if (list.length === 0)
return ;
root.setMany({
"input.kb_layout": list.map((e) => {
return e.layout;
}).join(","),
"input.kb_variant": list.some((e) => {
return e.variant !== "";
}) ? list.map((e) => {
return e.variant;
}).join(",") : ""
});
}
function layoutId(e) {
return e.variant !== "" ? e.layout + "(" + e.variant + ")" : e.layout;
}
function kbOptions() {
return String(root.value("input.kb_options") || "").split(",").map((o) => {
return o.trim();
}).filter((o) => {
return o !== "";
});
}
// the option of a group in force, "" for none; caps covers ctrl:nocaps too
function inGroup(group, o) {
if (group === "caps")
return o.indexOf("caps:") === 0 || o === "ctrl:nocaps" || o === "ctrl:swapcaps";
return o.indexOf(group + ":") === 0;
}
function kbOption(group) {
return root.kbOptions().find((o) => {
return root.inGroup(group, o);
}) || "";
}
// swaps one group's option and keeps every other option as it was
function setKbOption(group, option) {
const rest = root.kbOptions().filter((o) => {
return !root.inGroup(group, o);
});
if (option !== "")
rest.push(option);
root.set("input.kb_options", rest.join(","));
}
// options whose own value is known go back to it live; the rest take a reload
property var restoreQueue: []
function resetKeys(list) {
const m = Object.assign({}, root.mine);
const queue = root.restoreQueue.slice();
for (const k of list) {
delete m[k];
// a colour set by a choice goes with the choice, and the other way round
if (k === "general.col.active_border")
delete m["lucid.border"];
if (k === "general.col.inactive_border")
delete m["lucid.inactive_border"];
const option = root.targetOf(k, "").option || k;
if (option !== "" && (root.status.base || {})[option] !== undefined && queue.indexOf(option) === -1)
queue.push(option);
}
root.restoreQueue = queue;
Prefs.hyprOptions = JSON.stringify(m);
}
// what you set by hand to its config value, or what the config has since
// come to set the same, stops being Settings'
function prune() {
const same = Object.keys(root.mine).filter((k) => {
return root.isDefault(k, root.mine[k]);
});
if (same.length > 0)
root.resetKeys(same);
}
// --- Hyprland's side
function normalize(o) {
for (const t of ["int", "float", "bool", "str", "css", "gradient", "vec2", "custom"]) {
if (o[t] === undefined)
continue;
if (t === "css") {
const parts = String(o.css).trim().split(/\s+/).map(Number);
return parts.every((p) => {
return p === parts[0];
}) ? parts[0] : String(o.css);
}
// an empty string nobody set reads back as a marker
if (t === "str" && o.str === "[[EMPTY]]")
return "";
return o[t];
}
return undefined;
}
function refresh() {
if (readProc.running)
refreshAgain.restart();
else
readProc.running = true;
}
function write() {
if (!Prefs.loaded || !dataFile.ready || root.rendered === dataFile.current)
return ;
// Hyprland has no way to unset an option: one whose own value is known
// is put back to it, anything else dropped takes a reload
const after = root.keysIn(root.rendered);
const gone = root.keysIn(dataFile.current).filter((k) => {
return after.indexOf(k) === -1;
});
dataFile.restoring = gone.filter((k) => {
return root.restoreQueue.indexOf(k) !== -1;
});
dataFile.dropped = gone.length > dataFile.restoring.length || root.reloadKeys.some((k) => {
return root.lineOf(root.rendered, k) !== root.lineOf(dataFile.current, k);
});
dataFile.nudge = root.nudgeKeys.some((k) => {
return root.lineOf(root.rendered, k) !== root.lineOf(dataFile.current, k);
});
root.restoreQueue = [];
dataFile.current = root.rendered;
dataFile.setText(root.rendered);
}
onRenderedChanged: writeDebounce.restart()
Timer {
id: writeDebounce
interval: 150
onTriggered: root.write()
}
Timer {
id: refreshAgain
interval: 250
onTriggered: root.refresh()
}
Connections {
function onLoadedChanged() {
writeDebounce.restart();
}
target: Prefs
}
Connections {
function onRawEvent(event) {
if (event.name === "configreloaded")
refreshAgain.restart();
}
target: Hyprland
}
// Glass repaints the border from the new palette; read it back after
Connections {
function onRecoloured() {
refreshAgain.restart();
}
target: Theme
}
Process {
id: readProc
command: ["hyprctl", "-j", "--batch", root.keys.map((k) => {
return "getoption " + k;
}).join("; ")]
stdout: StdioCollector {
onStreamFinished: {
const out = {};
for (const chunk of this.text.match(/\{[^{}]*\}/g) || []) {
try {
const o = JSON.parse(chunk);
const v = root.normalize(o);
if (o.option && v !== undefined)
out[String(o.option).replace(/:/g, ".")] = v;
} catch (e) {
}
}
root.live = out;
root.liveRead = true;
}
}
}
// fetches the plugin, compiles it against the hyprland package's own
// headers and loads it; it says why when it cannot
Process {
id: pluginProc
command: ["bash", "-c", "\"$0\" build && \"$0\" load", root.pluginScript]
onExited: (code) => {
root.pluginBuilding = false;
const lines = pluginErr.text.trim().split("\n");
root.pluginError = code === 0 ? "" : (lines[lines.length - 1] || "the plugin did not build").replace(/^cursor-plugin: /, "");
root.refresh();
}
stderr: StdioCollector {
id: pluginErr
}
}
FileView {
path: root.pluginScript
printErrors: false
onLoaded: root.pluginScriptFound = true
onLoadFailed: root.pluginScriptFound = false
}
FileView {
id: dataFile
property bool ready: false
property string current: ""
property bool dropped: false
property var restoring: []
property bool nudge: false
path: root.dataPath
blockLoading: true
printErrors: false
onLoaded: {
dataFile.current = dataFile.text();
dataFile.ready = true;
writeDebounce.restart();
}
onLoadFailed: {
dataFile.current = "";
dataFile.ready = true;
writeDebounce.restart();
}
onSaved: {
root.applySaved(dataFile.dropped, dataFile.restoring, dataFile.nudge);
dataFile.dropped = false;
dataFile.restoring = [];
dataFile.nudge = false;
refreshAgain.restart();
}
}
Process {
id: applyProc
onExited: {
Pointer.poke();
if (root._pending) {
const p = root._pending;
root._pending = null;
root.applySaved(p.reload, p.restoring, p.nudge);
}
}
}
FileView {
path: root.statusPath
printErrors: false
watchChanges: true
onFileChanged: reload()
onLoaded: {
try {
root.status = JSON.parse(text()) || {};
} catch (e) {
root.status = {};
}
}
onLoadFailed: root.status = {}
}
// missing after --no-hypr, and the page says so
FileView {
path: root.modulePath
printErrors: false
watchChanges: true
onFileChanged: reload()
onLoaded: {
root.moduleInstalled = true;
root.moduleProbed = true;
}
onLoadFailed: {
root.moduleInstalled = false;
root.moduleProbed = true;
}
}
// the modules hyprland.lua requires after this one, as files
function laterPaths(text) {
const lines = String(text || "").split("\n");
const at = lines.findIndex((l) => {
return /^\s*require\s*\(?\s*["']modules\.settings["']/.test(l);
});
if (at === -1)
return [];
const out = [];
for (const l of lines.slice(at + 1)) {
const m = /^\s*(?:pcall\s*\(\s*)?require\s*[(,]?\s*["']([^"']+)["']/.exec(l);
if (m)
out.push(root.hyprDir + "/" + m[1].replace(/\./g, "/") + ".lua");
}
return out;
}
function readLater() {
const paths = root.laterPaths(hyprlandLua.loaded ? hyprlandLua.text() : "");
if (paths.length === 0) {
root.laterFiles = [];
return ;
}
laterProc.command = ["bash", "-c", "for p; do [ -f \"$p\" ] || continue; printf '\\036%s\\037' \"${p##*/}\"; cat \"$p\"; done", "later"].concat(paths);
laterProc.running = true;
}
FileView {
id: hyprlandLua
path: root.hyprDir + "/hyprland.lua"
printErrors: false
watchChanges: true
onFileChanged: reload()
onLoaded: root.readLater()
}
Process {
id: laterProc
stdout: StdioCollector {
onStreamFinished: {
root.laterFiles = this.text.split("\u001e").filter((c) => {
return c.indexOf("\u001f") !== -1;
}).map((c) => {
const i = c.indexOf("\u001f");
return {
"name": c.slice(0, i),
"text": c.slice(i + 1)
};
});
}
}
}
onStatusChanged: {
if ((root.status.overridden || []).length > 0)
root.readLater();
pruneLater.restart();
}
// after the status settles, not in the middle of a write
Timer {
id: pruneLater
interval: 400
onTriggered: root.prune()
}
}