Add glassMxrph shell sources

Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-10-07 22:36:17 +02:00
commit 99e64a7713
433 files changed
+57792

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
function canonical(id) { return String(id || "").replace(/\.desktop$/i, ""); }
function normalized(id) { return canonical(id).toLowerCase(); }
// Lookup tables for one catalog array. Hyprland emits events (title changes)
// several times a second; scanning every entry per window per event dominated
// idle JavaScript time. The catalog array is replaced, not mutated, on change.
let indexedEntries = null, index = null;
function lookup(entries) {
if (entries === indexedEntries) return index;
const add = (map, key, entry) => { if (!map.has(key)) map.set(key, []); map.get(key).push(entry); };
index = {canonical: new Map(), normalized: new Map(), startup: new Map()};
for (const e of entries) {
if (!index.canonical.has(canonical(e.id))) index.canonical.set(canonical(e.id), e);
add(index.normalized, normalized(e.id), e);
if (e.startupClass) add(index.startup, e.startupClass.toLowerCase(), e);
}
indexedEntries = entries;
return index;
}
function match(appId, initialClass, entries, overrides) {
const candidates = [appId, initialClass].filter(Boolean);
const table = lookup(entries);
for (const key of candidates) {
const override = overrides[key];
if (override) return table.canonical.get(canonical(override)) || null;
}
for (const key of candidates) {
const exact = table.normalized.get(normalized(key)) || [];
if (exact.length === 1) return exact[0];
const startup = table.startup.get(key.toLowerCase()) || [];
if (startup.length === 1) return startup[0];
}
return null; // Never guess from titles, substrings, or an ambiguous class.
}
function group(entries, windows, pinned, overrides, showRunning) {
const result = [], byId = new Map();
function add(id, entry, isPinned, label) {
const row = {id:id, entry:entry, pinned:isPinned, name:entry ? entry.name : label || id, windows:[], focused:false};
byId.set(id, row); result.push(row); return row;
}
for (const id of pinned) {
const key = canonical(id);
if (!byId.has(key)) add(key, lookup(entries).canonical.get(key) || null, true);
}
for (const window of windows) {
const entry = match(window.appId, window.initialClass, entries, overrides);
const id = entry ? canonical(entry.id) : "window:" + (window.appId || window.initialClass || window.address);
let row = byId.get(id);
if (!row && showRunning) row = add(id, entry, false, window.appId || window.title);
if (row) { row.windows.push(window); row.focused = row.focused || window.active; }
}
return result;
}
function reorder(pinned, source, target) {
const result = pinned.slice();
const from = result.findIndex(id => canonical(id) === canonical(source));
const to = result.findIndex(id => canonical(id) === canonical(target));
if (from < 0 || to < 0 || from === to) return result;
result.splice(to, 0, result.splice(from, 1)[0]);
return result;
}
@@ -0,0 +1,39 @@
pragma Singleton
import QtQuick
import Quickshell
import "AppMatching.js" as Matching
Singleton {
id: root
readonly property var entries: DesktopEntries.applications.values
readonly property var launchable: entries.filter(e => !e.noDisplay).slice().sort((a, b) => a.name.localeCompare(b.name))
property string error: ""
function byId(id) {
return entries.find(e => Matching.canonical(e.id) === Matching.canonical(id)) || null;
}
function icon(entry) {
return entry && entry.icon ? Quickshell.iconPath(entry.icon, true) : "";
}
function launch(entry, action) {
if (!entry) {
error = "This desktop entry is no longer installed.";
return false;
}
if (entry.runInTerminal) {
const terminal = ConfigService.data.dock.terminalCommand;
if (!terminal.length) {
error = "Set dock.terminalCommand to a terminal command argument array before launching terminal applications.";
return false;
}
Quickshell.execDetached({
command: terminal.concat(action ? action.command : entry.command),
workingDirectory: entry.workingDirectory
});
} else if (action)
action.execute();
else
entry.execute();
error = "";
return true;
}
}
+41
View File
@@ -0,0 +1,41 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Services.Pipewire
Singleton {
id: root
property var backend: Pipewire
readonly property var sink: backend.defaultAudioSink
readonly property var source: backend.defaultAudioSource
readonly property var outputs: backend.nodes.values.filter(n => n.audio && n.isSink && !n.isStream)
readonly property var inputs: backend.nodes.values.filter(n => n.audio && !n.isSink && !n.isStream)
readonly property bool available: backend.ready
PwObjectTracker {
objects: root.backend === Pipewire ? [root.sink, root.source].filter(n => n !== null) : []
}
function volume(input, value) {
const node = input ? source : sink;
if (!node || !node.audio || !Number.isFinite(value))
return false;
node.audio.volume = Math.max(0, Math.min(1, value));
return true;
}
function mute(input) {
const node = input ? source : sink;
if (!node || !node.audio)
return false;
node.audio.muted = !node.audio.muted;
return true;
}
function select(input, index) {
const node = (input ? inputs : outputs)[index];
if (!node)
return false;
if (input)
backend.preferredDefaultAudioSource = node;
else
backend.preferredDefaultAudioSink = node;
return true;
}
}
+54
View File
@@ -0,0 +1,54 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Bluetooth
Singleton {
id: root
property var backend: Bluetooth
property string adapterId: ""
readonly property var adapters: backend.adapters.values
readonly property var adapter: adapters.find(a => a.adapterId === adapterId) || backend.defaultAdapter
readonly property var devices: adapter ? adapter.devices.values : []
readonly property bool canToggle: !!adapter && adapter.state !== BluetoothAdapterState.Blocked
readonly property bool enabled: !!adapter && adapter.enabled
readonly property string summary: devices.filter(d => d.connected).map(d => d.name).join(", ") || (enabled ? "On" : "Off")
property string error: ""
property var pending: null
function toggle() {
if (!adapter || adapter.state === BluetoothAdapterState.Blocked)
return false;
error = "";
adapter.enabled = !enabled;
return true;
}
function connectDevice(device) {
if (!device || !device.paired || !enabled || pending)
return false;
error = "";
pending = device;
timeout.restart();
if (device.connected)
device.disconnect();
else
device.connect();
return true;
}
Connections {
target: root.pending
function onStateChanged() {
if (root.pending && (root.pending.state === BluetoothDeviceState.Connected || root.pending.state === BluetoothDeviceState.Disconnected)) {
timeout.stop();
root.pending = null;
}
}
}
Timer {
id: timeout
interval: 15000
onTriggered: {
root.error = "No connection confirmation received. Open the Bluetooth manager for details.";
root.pending = null;
}
}
}
+60
View File
@@ -0,0 +1,60 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
Singleton {
id: root
property int consumers: 0
// Desktop visualizer widgets request Cava regardless of the media card's toggle.
property int widgetConsumers: 0
property var bars: Array(24).fill(0)
property string error: ""
property int frames: 0
property bool failed: false
readonly property bool wanted: ConfigService.ready && MediaService.playing && ((ConfigService.data.media.showCava && consumers > 0) || widgetConsumers > 0)
onWantedChanged: {
if (!wanted) {
failed = false;
error = "";
bars = Array(24).fill(0);
}
}
Process {
id: process
command: ["python3", Quickshell.shellPath("helpers/cava.py"), Quickshell.shellPath("config/cava.conf")]
running: root.wanted && !root.failed
stdout: SplitParser {
onRead: data => {
const values = data.trim().split(";").filter(v => v.length).map(Number);
if (values.length === 24 && values.every(v => Number.isFinite(v) && v >= 0 && v <= 1000)) {
root.bars = values.map(v => v / 1000);
root.frames++;
}
}
}
stderr: StdioCollector {
id: errors
}
// Quickshell 0.3.1 metadata omits QProcess::ExitStatus.
// qmllint disable signal-handler-parameters
onExited: code => {
if (root.wanted) {
root.failed = true;
root.error = errors.text.trim().slice(0, 300) || "Cava stopped (" + code + ")";
}
}
}
IpcHandler {
target: "cava"
function status(): string {
return JSON.stringify({
running: process.running,
error: root.error,
bars: root.bars,
frames: root.frames,
consumers: root.consumers
});
}
}
}
+135
View File
@@ -0,0 +1,135 @@
function merge(defaults, user) {
if (Array.isArray(defaults)) {
if (user !== undefined && !Array.isArray(user)) throw Error("Expected a configuration array");
return user === undefined ? defaults.slice() : user.slice();
}
if (defaults && typeof defaults === "object") {
if (user !== undefined && (!user || typeof user !== "object" || Array.isArray(user))) throw Error("Expected a configuration object");
const result = Object.assign({}, user && typeof user === "object" && !Array.isArray(user) ? user : {});
for (const key of Object.keys(defaults)) result[key] = merge(defaults[key], result[key]);
return result;
}
return user === undefined ? defaults : user;
}
function validate(c) {
if (!c || typeof c !== "object" || Array.isArray(c)) throw Error("Configuration must be an object");
if (c.schemaVersion !== 3) throw Error("Unsupported configuration version");
if (!["system", "custom", "matugen"].includes(c.appearance.accentSource)) throw Error("Invalid accent source");
if (!/^#[0-9a-fA-F]{6}$/.test(c.appearance.customAccent)) throw Error("Accent must be #RRGGBB");
if (!/^#[0-9a-fA-F]{6}$/.test(c.appearance.glassTint)) throw Error("Glass tint must be #RRGGBB");
for (const [key, min, max] of [["glassOpacity",0.15,1],["borderOpacity",0,1],["radius",0,48]]) {
const n = c.appearance[key];
if (typeof n !== "number" || !Number.isFinite(n) || n < min || n > max) throw Error("Invalid " + key);
}
if (typeof c.animation.reducedMotion !== "boolean" || !Number.isFinite(c.animation.duration) || c.animation.duration < 0 || c.animation.duration > 1000) throw Error("Invalid animation settings");
if (!Number.isFinite(c.bar.height) || c.bar.height < 32 || c.bar.height > 80 || !Number.isFinite(c.bar.margin) || c.bar.margin < 0 || c.bar.margin > 100) throw Error("Invalid bar geometry");
if(!Number.isInteger(c.bar.workspaces.count) || c.bar.workspaces.count<1 || c.bar.workspaces.count>20 || !["numbers","roman","dots","pacman"].includes(c.bar.workspaces.style) || ["showDate","use24Hour","showSeconds"].some(k=>typeof c.bar.clock[k]!=="boolean"))throw Error("Invalid bar module options");
const cava=c.bar.cava;
if(!cava || !Number.isInteger(cava.bars) || cava.bars<4 || cava.bars>24 || !["bars","mirror"].includes(cava.style) || typeof cava.hideWhenIdle!=="boolean")throw Error("Invalid bar visualizer preferences");
const validModules = list => {
const seen = new Set();
if (!Array.isArray(list)) throw Error("Bar modules must be an array");
for (const m of list) {
if (!m || typeof m.id !== "string" || seen.has(m.id) || !["left","center","right"].includes(m.position) || typeof m.enabled !== "boolean") throw Error("Invalid bar module");
// Optional per-module options (the cog in Settings → Bar).
if (m.options !== undefined && (!m.options || typeof m.options !== "object" || Array.isArray(m.options))) throw Error("Invalid bar module options");
seen.add(m.id);
}
};
validModules(c.bar.modules);
// Per-screen layouts: screen name -> {modules}.
if (!c.bar.screens || typeof c.bar.screens !== "object" || Array.isArray(c.bar.screens)) throw Error("Invalid per-screen bar layouts");
for (const name of Object.keys(c.bar.screens)) {
const entry = c.bar.screens[name];
if (!name || !entry || typeof entry !== "object") throw Error("Invalid per-screen bar layout");
validModules(entry.modules);
}
if (typeof c.tray.enabled !== "boolean" || typeof c.tray.hoverMenus !== "boolean") throw Error("Invalid tray toggle");
for (const [key, min, max] of [["hoverDelay", 100, 2000], ["iconSize", 16, 32], ["spacing", 0, 24]]) {
if (!Number.isInteger(c.tray[key]) || c.tray[key] < min || c.tray[key] > max) throw Error("Invalid tray " + key);
}
if (!["pill", "transparent", "icons"].includes(c.tray.background)) throw Error("Invalid tray background");
if (!["bottom", "left", "right"].includes(c.dock.position) || !["always", "auto", "intelligent"].includes(c.dock.visibility)) throw Error("Invalid dock position/visibility");
if (typeof c.dock.monitor !== "string" || !c.dock.monitor.length) throw Error("Invalid dock monitor");
for (const key of ["enabled", "magnification", "showRunningApps", "runningIndicators", "tooltips"]) if (typeof c.dock[key] !== "boolean") throw Error("Invalid dock " + key);
for (const [key,min,max] of [["iconSize",24,80],["spacing",0,24],["margin",0,80],["magnificationStrength",0,0.8],["animationSpeed",0.25,3]]) {
if (!Number.isFinite(c.dock[key]) || c.dock[key] < min || c.dock[key] > max) throw Error("Invalid dock " + key);
}
if (!Array.isArray(c.dock.pinnedApps) || c.dock.pinnedApps.some(id => typeof id !== "string" || !id.length || id.includes("/")) || new Set(c.dock.pinnedApps.map(id => id.replace(/\.desktop$/i, ""))).size !== c.dock.pinnedApps.length) throw Error("Invalid pinned apps");
if (!Array.isArray(c.dock.terminalCommand) || c.dock.terminalCommand.some(arg => typeof arg !== "string")) throw Error("Terminal command must be an argument array");
if (!c.dock.appOverrides || typeof c.dock.appOverrides !== "object" || Array.isArray(c.dock.appOverrides) || Object.values(c.dock.appOverrides).some(id => typeof id !== "string")) throw Error("Invalid app matching overrides");
if (!Number.isInteger(c.launcher.maxResults) || c.launcher.maxResults<10 || c.launcher.maxResults>100 || !Number.isFinite(c.launcher.width) || c.launcher.width<420 || c.launcher.width>960 || typeof c.launcher.showDescriptions!=="boolean" || typeof c.launcher.recentFiles!=="boolean") throw Error("Invalid launcher preferences");
for (const key of ["highlights","shadows"]) if(typeof c.appearance[key]!=="boolean")throw Error("Invalid appearance toggle");
if(!Number.isFinite(c.appearance.panelOpacity) || c.appearance.panelOpacity<0.15 || c.appearance.panelOpacity>1)throw Error("Invalid panel opacity");
if(!Number.isFinite(c.animation.intensity) || c.animation.intensity<0 || c.animation.intensity>1)throw Error("Invalid animation intensity");
if(typeof c.matugen.executable!=="string" || !c.matugen.executable.trim() || typeof c.matugen.regenerateOnWallpaperChange!=="boolean" || !Number.isFinite(c.matugen.contrast) || c.matugen.contrast < -1 || c.matugen.contrast>1)throw Error("Invalid Matugen options");
if(!["scheme-content","scheme-expressive","scheme-fidelity","scheme-fruit-salad","scheme-monochrome","scheme-neutral","scheme-rainbow","scheme-tonal-spot","scheme-vibrant","scheme-smart"].includes(c.matugen.scheme))throw Error("Unsupported Matugen scheme");
if(!["native","auto","serpantinum","awww","custom"].includes(c.wallpaper.backend) || !Array.isArray(c.wallpaper.directories) || c.wallpaper.directories.some(p=>typeof p!=="string" || !p.length) || !Array.isArray(c.wallpaper.command) || c.wallpaper.command.some(a=>typeof a!=="string") || typeof c.wallpaper.paletteMonitor!=="string")throw Error("Invalid wallpaper preferences");
if(!c.wallpaper.byMonitor || typeof c.wallpaper.byMonitor!=="object" || Array.isArray(c.wallpaper.byMonitor) || Object.values(c.wallpaper.byMonitor).some(p=>typeof p!=="string"))throw Error("Invalid wallpaper map");
if(!c.wallpaper.providerPaths || typeof c.wallpaper.providerPaths!=="object" || Array.isArray(c.wallpaper.providerPaths) || Object.values(c.wallpaper.providerPaths).some(p=>typeof p!=="string"))throw Error("Invalid provider wallpaper map");
for(const key of ["showAlbumArt","showProgress","showAlbum","showCava"])if(typeof c.media[key]!=="boolean")throw Error("Invalid media toggle");
if(typeof c.media.preferredPlayer!=="string")throw Error("Invalid media preferences");
const lock=c.lock;
if(!lock || ["enabled","glass","media","powerButtons"].some(k=>typeof lock[k]!=="boolean") || !["wallpaper","screenshot"].includes(lock.backdrop) || typeof lock.pamService!=="string" || !/^[A-Za-z0-9._-]{0,64}$/.test(lock.pamService))throw Error("Invalid lock screen preferences");
const dw=c.desktopWidgets;
if(!dw || dw.version!==1 || typeof dw.grid!=="boolean" || !Array.isArray(dw.items))throw Error("Invalid desktop widgets");
const widgetIds=new Set();
for(const w of dw.items) {
// Unknown types are preserved (and skipped when rendering) for forward compatibility.
if(!w || typeof w.id!=="string" || !/^[a-z0-9-]{1,40}$/.test(w.id) || widgetIds.has(w.id) || typeof w.type!=="string" || typeof w.variant!=="string" || typeof w.monitor!=="string" || ![w.x,w.y,w.w,w.h,w.opacity].every(Number.isFinite) || w.w<40 || w.h<40 || w.w>4000 || w.h>4000 || w.opacity<0.1 || w.opacity>1 || (w.options!==undefined && (!w.options || typeof w.options!=="object" || Array.isArray(w.options))))throw Error("Invalid desktop widget");
widgetIds.add(w.id);
}
if(!c.plugins || !Array.isArray(c.plugins.enabled) || c.plugins.enabled.some(id=>typeof id!=="string" || !id))throw Error("Invalid plugin preferences");
const dash=c.dashboard;
if(!dash || ["enabled","openFromClock","rememberTab","easyEffects"].some(k=>typeof dash[k]!=="boolean") || !["top-left","top-center","top-right","center"].includes(dash.position) || !Array.isArray(dash.tabs))throw Error("Invalid dashboard preferences");
const dashTabs=new Set();
for(const t of dash.tabs) { if(!t || typeof t.id!=="string" || dashTabs.has(t.id) || typeof t.enabled!=="boolean")throw Error("Invalid dashboard tab"); dashTabs.add(t.id); }
if(typeof c.osd.enabled!=="boolean" || !["slide","drop","fade","shrink"].includes(c.osd.animation) || !["top-right","top-center","bottom-center"].includes(c.osd.position) || !Number.isInteger(c.osd.timeout) || c.osd.timeout<500 || c.osd.timeout>5000 || !Number.isInteger(c.osd.step) || c.osd.step<1 || c.osd.step>20)throw Error("Invalid OSD preferences");
if(c.controlCenter.version !== 1 || !Number.isFinite(c.controlCenter.width) || c.controlCenter.width < 320 || c.controlCenter.width > 600 || !Array.isArray(c.controlCenter.modules))throw Error("Invalid Control Center configuration");
const controlIds=new Set();
for(const m of c.controlCenter.modules) { if(!m || typeof m.id!=="string" || controlIds.has(m.id) || typeof m.enabled!=="boolean")throw Error("Invalid Control Center module"); controlIds.add(m.id); }
for(const group of [c.system.brightness,c.system.nightLight]) for(const key of ["statusCommand","setCommand"])if(!Array.isArray(group[key]) || group[key].some(v=>typeof v!=="string" || !v.length))throw Error("Provider command must be an argument array");
if(typeof c.system.brightness.device!=="string" || !c.system.brightness.device || !Number.isInteger(c.system.nightLight.temperature) || c.system.nightLight.temperature<1000 || c.system.nightLight.temperature>6500 || !Array.isArray(c.system.power.lockCommand) || c.system.power.lockCommand.some(v=>typeof v!=="string" || !v.length))throw Error("Invalid system provider settings");
if(!Number.isInteger(c.metrics.interval) || c.metrics.interval<1 || c.metrics.interval>30)throw Error("Invalid metrics geometry or interval");
if(!Array.isArray(c.metrics.storagePaths) || c.metrics.storagePaths.length>8 || c.metrics.storagePaths.some(p=>typeof p!=="string" || !p.startsWith("/") || p.includes("\u0000")) || new Set(c.metrics.storagePaths).size!==c.metrics.storagePaths.length || typeof c.metrics.networkInterface!=="string" || !c.metrics.networkInterface || typeof c.metrics.gpu!=="string" || !c.metrics.gpu)throw Error("Invalid metrics sources");
if(!Array.isArray(c.wallpaper.history) || c.wallpaper.history.length>50 || c.wallpaper.history.some(p=>typeof p!=="string"))throw Error("Invalid wallpaper history");
if(typeof c.hyprglass.enabled!=="boolean" || typeof c.hyprglass.layers!=="boolean" || typeof c.hyprglass.effectEnabled!=="boolean")throw Error("Invalid glass toggle");
for(const [key,min,max] of [["blur_strength",0,5],["blur_iterations",1,5],["refraction_strength",0,8],["chromatic_aberration",0,1],["fresnel_strength",0,1],["specular_strength",0,1],["edge_thickness",0,.15],["lens_distortion",0,1],["brightness",.2,2],["contrast",.2,2],["saturation",0,2],["vibrancy",0,1],["adaptive_dim",0,1]])if(!Number.isFinite(c.hyprglass.values[key]) || c.hyprglass.values[key]<min || c.hyprglass.values[key]>max)throw Error("Invalid glass "+key);
if(!Number.isInteger(c.hyprglass.values.blur_iterations))throw Error("Invalid blur passes");
return c;
}
function load(defaults, user) {
if (!user || typeof user !== "object" || Array.isArray(user)) throw Error("Configuration must be an object");
const migrated = JSON.parse(JSON.stringify(user));
const version = migrated.schemaVersion === undefined ? 1 : migrated.schemaVersion;
if (version !== 1 && version !== 2 && version !== 3) throw Error("Unsupported configuration version");
if (version === 1) {
// Preserve every existing module and its order. Insert the newly available tray
// before system, or append when the user has removed that module.
if (migrated.bar && Array.isArray(migrated.bar.modules) && !migrated.bar.modules.some(m => m.id === "tray")) {
const index = migrated.bar.modules.findIndex(m => m.id === "system");
migrated.bar.modules.splice(index < 0 ? migrated.bar.modules.length : index, 0, {id:"tray", position:"right", enabled:true});
}
migrated.schemaVersion = 2;
}
if (migrated.controlCenter !== undefined && (!migrated.controlCenter || typeof migrated.controlCenter !== "object" || Array.isArray(migrated.controlCenter))) throw Error("Control Center must be an object");
// Phase 1–6 saved an unused empty list. Migrate it exactly once; retain
// nonempty custom layouts and deliberate empty layouts after version 1.
if (!migrated.controlCenter || migrated.controlCenter.version === undefined) {
migrated.controlCenter = Object.assign({}, migrated.controlCenter || {});
if (migrated.controlCenter.modules === undefined || (Array.isArray(migrated.controlCenter.modules) && migrated.controlCenter.modules.length === 0))
migrated.controlCenter.modules = defaults.controlCenter.modules;
migrated.controlCenter.version = 1;
}
migrated.schemaVersion = 3;
return validate(merge(defaults, migrated));
}
function update(config, path, value) {
const result = JSON.parse(JSON.stringify(config));
const keys = path.split(".");
if (keys.some(k => ["__proto__","constructor","prototype"].includes(k))) throw Error("Invalid setting path");
let target = result;
for (let i = 0; i < keys.length - 1; ++i) target = target[keys[i]];
target[keys[keys.length - 1]] = value;
return validate(result);
}
+48
View File
@@ -0,0 +1,48 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import "ConfigLogic.js" as Logic
Singleton {
id: root
readonly property string directory: (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/glassMxrph"
property var data: ({})
property var defaults: ({})
property bool ready: false
property string error: ""
property bool writable: false
function value(path) { return path.split(".").reduce((object,key)=>object ? object[key] : undefined,data); }
function setValue(path, value) {
if (!ready || !writable) return false;
try { data = Logic.update(data, path, value); error=""; saveTimer.restart(); return true; }
catch (e) { error = String(e); return false; }
}
function readUser() {
try { data = Logic.load(defaults, JSON.parse(userFile.text())); error = ""; writable = true; }
catch (e) { error = "Configuration preserved: " + e; writable = false; }
ready = true;
}
FileView {
id: defaultsFile
path: Qt.resolvedUrl("../config/defaults.json").toString().replace("file://", "")
onLoaded: {
root.defaults = JSON.parse(text()); root.data = root.defaults;
userFile.path = root.directory + "/config.json";
}
}
FileView {
id: userFile
printErrors: false
atomicWrites: true
watchChanges: true
onLoaded: root.readUser()
onFileChanged: { saveTimer.stop(); reload(); }
onLoadFailed: error => {
root.ready = true;
if (error === FileViewError.FileNotFound) { root.writable = true; }
else { root.error = "Could not read configuration (" + error + ")"; root.writable = false; }
}
onSaveFailed: error => { root.error = "Could not save configuration (" + error + ")"; }
}
Timer { id: saveTimer; interval: 250; onTriggered: userFile.setText(JSON.stringify(root.data, null, 2) + "\n") }
}
+112
View File
@@ -0,0 +1,112 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
// EasyEffects 10-band equalizer (serpantinum-style presets). Band edits stay
// local and "pending" until applied; presets apply immediately.
Singleton {
id: root
property bool installed: false
property bool running: false
property bool bypass: false
property var bands: Array(10).fill(0)
property var saved: Array(10).fill(0)
property string preset: "Flat"
property var frequencies: [32, 63, 125, 250, 500, 1000, 2000, 4000, 8000, 16000]
property string error: ""
property bool known: false
readonly property bool busy: job.running
readonly property bool pending: bands.some((b, i) => b !== saved[i])
readonly property var presets: ({
Flat: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Bass: [5, 7, 5, 2, 1, 0, 0, 0, 1, 2],
Treble: [-2, -1, 0, 1, 2, 3, 4, 5, 6, 6],
Vocal: [-2, -1, 1, 3, 5, 5, 4, 2, 1, 0],
Pop: [2, 4, 2, 0, 1, 2, 4, 2, 1, 2],
Rock: [5, 4, 2, -1, -2, -1, 2, 4, 5, 6],
Jazz: [3, 3, 1, 1, 1, 1, 2, 1, 2, 3],
Classic: [0, 1, 2, 2, 2, 2, 1, 2, 3, 4]
})
readonly property var presetNames: ["Flat", "Bass", "Treble", "Vocal", "Pop", "Rock", "Jazz", "Classic"]
property var queued: null
function call(args) {
if (job.running) {
queued = args;
return;
}
job.command = ["python3", Quickshell.shellPath("helpers/easyeffects.py")].concat(args);
job.running = true;
}
function refresh() {
call(["status"]);
}
function setBand(index, gain) {
const next = bands.slice();
next[index] = Math.round(Math.max(-12, Math.min(12, gain)));
bands = next;
preset = "Custom";
}
function apply() {
if (installed)
call(["apply", JSON.stringify(bands), preset]);
}
function usePreset(name) {
if (!presets[name])
return;
bands = presets[name].slice();
preset = name;
apply();
}
function setBypass(on) {
bypass = on;
call(["bypass", on ? "on" : "off"]);
}
Process {
id: job
stdout: StdioCollector {
onStreamFinished: {
try {
const s = JSON.parse(text);
root.installed = s.installed;
root.running = s.running;
root.bypass = s.bypass;
root.error = s.error || "";
root.saved = s.bands;
root.frequencies = s.frequencies;
// Keep unapplied edits; otherwise follow the saved state.
if (!root.known || !root.pending) {
root.bands = s.bands.slice();
root.preset = s.preset;
}
root.known = true;
} catch (e) {
root.error = String(e);
}
}
}
onRunningChanged: if (!running && root.queued) {
const next = root.queued;
root.queued = null;
root.call(next);
}
}
IpcHandler {
target: "equalizer"
function status(): string {
return JSON.stringify({
installed: root.installed,
running: root.running,
bypass: root.bypass,
bands: root.bands,
preset: root.preset,
pending: root.pending,
error: root.error
});
}
function refresh(): void {
root.refresh();
}
}
}
+36
View File
@@ -0,0 +1,36 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Hyprland
Singleton {
id:root
property var state: ({})
property string error:""
property string notice:""
readonly property bool busy:job.running
property bool pendingReload:false
function probe() {if(!busy)job.start({action:"probe"});}
function apply(reloaded) {if(!busy)job.start({action:"apply",options:ConfigService.data.hyprglass,reloaded:!!reloaded});}
function restore() {if(!busy)job.start({action:"restore"});}
Component.onCompleted: startup.start()
Timer {
id:startup
interval:200
onTriggered:{if(!ConfigService.ready){restart();return;}if(ConfigService.data.hyprglass.enabled)root.apply(false);else root.probe();}
}
Connections {
target:Hyprland
function onRawEvent(event) {if(event.name==="configreloaded" && ConfigService.ready && ConfigService.data.hyprglass.enabled){root.pendingReload=true;reloadDelay.restart();}}
}
Timer {id:reloadDelay;interval:600;onTriggered:{if(root.busy){restart();return;}root.pendingReload=false;root.apply(true);}}
ProviderJob {
id:job
helper:"helpers/glass.py"
onFinished:(request,result)=>{
if(!result.ok){root.error=result.error;return;}
root.error="";root.state=result;root.notice=result.notice || "";
if(request.action==="apply")ConfigService.setValue("hyprglass.enabled",true);
if(request.action==="restore")ConfigService.setValue("hyprglass.enabled",false);
}
}
}
+65
View File
@@ -0,0 +1,65 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Hyprland
Singleton {
id: root
readonly property var visibleWorkspaces: Hyprland.workspaces.values.filter(w => w.active).map(w => w.id)
readonly property var windows: Hyprland.toplevels.values.map(t => {
const info = t.lastIpcObject || {};
return {
address: t.address,
handle: t.wayland,
appId: t.wayland ? t.wayland.appId : info.class || "",
initialClass: info.initialClass || "",
title: t.title,
active: t.activated,
monitor: t.monitor ? t.monitor.name : "",
workspace: t.workspace ? t.workspace.id : 0,
x: info.at ? info.at[0] : 0,
y: info.at ? info.at[1] : 0,
width: info.size ? info.size[0] : 0,
height: info.size ? info.size[1] : 0,
hidden: info.hidden === true || info.mapped === false,
fullscreen: info.fullscreen === 2,
floating: info.floating === true
};
}).filter(w => !w.hidden)
// Monitors whose desktop is hidden: a tiled or fullscreen window sits on
// their active workspace. Desktop widgets pause animation and sampling there.
readonly property var coveredMonitors: windows.filter(w => visibleWorkspaces.includes(w.workspace) && (!w.floating || w.fullscreen)).map(w => w.monitor)
readonly property bool needsGeometry: ConfigService.ready && ConfigService.data.dock.enabled && ConfigService.data.dock.visibility === "intelligent"
function focusWindow(address) {
const window = windows.find(w => w.address === address);
if (!window)
return false;
if (window.handle)
window.handle.activate();
else if (/^(0x)?[0-9a-f]+$/i.test(address))
Hyprland.dispatch("focuswindow address:" + (address.startsWith("0x") ? address : "0x" + address));
else
return false;
return true;
}
function closeWindow(address) {
const window = windows.find(w => w.address === address);
if (!window)
return false;
if (window.handle)
window.handle.close();
else if (/^(0x)?[0-9a-f]+$/i.test(address))
Hyprland.dispatch("closewindow address:" + (address.startsWith("0x") ? address : "0x" + address));
else
return false;
return true;
}
// Native IPC, not subprocess polling. Hyprland emits no continuous resize event.
Timer {
interval: 500
repeat: true
running: root.needsGeometry
triggeredOnStart: true
onTriggered: Hyprland.refreshToplevels()
}
}
+114
View File
@@ -0,0 +1,114 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Services.Mpris
Singleton {
id: root
readonly property var players: Mpris.players.values
property string selected: ""
readonly property string preferred: ConfigService.ready ? ConfigService.data.media.preferredPlayer : "automatic"
readonly property var player: players.find(p => p.dbusName === selected) || players.find(p => p.dbusName === preferred || p.desktopEntry === preferred) || players.find(p => p.isPlaying) || players[0] || null
readonly property bool playing: !!player && player.isPlaying
readonly property string title: player ? (player.trackTitle || "Untitled track") : "Nothing playing"
readonly property string artist: player ? player.trackArtist : "Open a music or video player"
readonly property string album: player ? player.trackAlbum : ""
readonly property string artwork: player ? player.trackArtUrl : ""
readonly property real length: player && player.lengthSupported ? Math.max(0, player.length) : 0
property real position: 0
property int progressConsumers: 0
readonly property bool seekable: !!player && player.canControl && player.canSeek && player.positionSupported && length > 0
onPreferredChanged: selected = ""
onPlayerChanged: refreshPosition()
onPlayingChanged: refreshPosition()
onLengthChanged: refreshPosition()
function refreshPosition() {
position = player && player.positionSupported ? Math.max(0, Math.min(length || Infinity, player.position)) : 0;
}
function choose(name) {
if (name && !players.some(p => p.dbusName === name))
return false;
selected = name;
return true;
}
function toggle() {
if (!player || !player.canControl || !player.canTogglePlaying)
return false;
player.togglePlaying();
return true;
}
function previous() {
if (!player || !player.canControl || !player.canGoPrevious)
return false;
player.previous();
return true;
}
function next() {
if (!player || !player.canControl || !player.canGoNext)
return false;
player.next();
return true;
}
function seek(value) {
if (!seekable || !Number.isFinite(value))
return false;
player.position = Math.max(0, Math.min(length, value));
refreshPosition();
return true;
}
function time(value) {
const s = Math.max(0, Math.floor(value));
return Math.floor(s / 60) + ":" + String(s % 60).padStart(2, "0");
}
Timer {
interval: 500
repeat: true
running: root.playing && root.progressConsumers > 0
onTriggered: root.refreshPosition()
}
Connections {
target: root.player
function onPositionChanged() {
root.refreshPosition();
}
function onTrackChanged() {
root.refreshPosition();
}
}
IpcHandler {
target: "media"
function status(): string {
return JSON.stringify({
players: root.players.map(p => ({
id: p.dbusName,
name: p.identity
})),
selected: root.player ? root.player.dbusName : "",
title: root.title,
artist: root.artist,
album: root.album,
artwork: root.artwork,
playing: root.playing,
position: root.position,
length: root.length,
seekable: root.seekable
});
}
function select(name: string): bool {
return root.choose(name);
}
function toggle(): bool {
return root.toggle();
}
function next(): bool {
return root.next();
}
function previous(): bool {
return root.previous();
}
function seek(seconds: real): bool {
return root.seek(seconds);
}
}
}
+124
View File
@@ -0,0 +1,124 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
Singleton {
id: root
property int consumers: 0
property var snapshot: ({})
property var history: []
property string error: ""
property int retryDelay: 1000
property double nextStart: 0
property int samples: 0
property double lastSample: 0
property bool stale: true
readonly property bool wanted: ConfigService.ready && consumers > 0
readonly property string options: ConfigService.ready ? JSON.stringify({
interval: ConfigService.data.metrics.interval,
storagePaths: ConfigService.data.metrics.storagePaths,
networkInterface: ConfigService.data.metrics.networkInterface
}) : "{}"
readonly property var cpu: snapshot.cpu || ({})
readonly property var ram: snapshot.ram || ({})
readonly property var network: snapshot.network || ({})
readonly property var gpus: snapshot.gpus || []
readonly property var gpu: (ConfigService.data.metrics.gpu === "auto" ? gpus[0] : gpus.find(g => g.id === ConfigService.data.metrics.gpu)) || ({})
onOptionsChanged: {
process.running = false;
root.stale = true;
root.lastSample = 0;
root.history = [];
root.nextStart = 0;
root.retryDelay = 1000;
}
// Idle shutdown keeps the last sample: consumers that pause briefly (desktop
// widgets under windows) resume with it until it ages past the stale limit.
onWantedChanged: if (!wanted)
process.running = false
function value(n, suffix, digits) {
return stale || n === undefined || n === null || !Number.isFinite(n) ? "—" : n.toFixed(digits || 0) + (suffix || "");
}
function bytes(n) {
if (stale || n === undefined || n === null || !Number.isFinite(n))
return "—";
const units = ["B", "KiB", "MiB", "GiB", "TiB"];
let i = 0;
while (n >= 1024 && i < units.length - 1) {
n /= 1024;
i++;
}
return n.toFixed(i > 1 ? 1 : 0) + " " + units[i];
}
Timer {
interval: 1000
repeat: true
running: root.wanted
triggeredOnStart: true
onTriggered: {
if (!process.running && Date.now() >= root.nextStart) {
process.command = ["python3", Quickshell.shellPath("helpers/metrics.py"), root.options];
process.running = true;
}
root.stale = !root.lastSample || Date.now() - root.lastSample > Math.max(10000, ConfigService.data.metrics.interval * 3000);
}
}
Process {
id: process
stdout: SplitParser {
onRead: data => {
try {
const state = JSON.parse(data);
if (!state.cpu || !state.ram || !Array.isArray(state.gpus) || !state.network)
throw Error("Invalid metrics snapshot");
root.snapshot = state;
root.lastSample = Date.now();
root.stale = false;
root.error = "";
root.samples++;
root.retryDelay = 1000;
root.history = root.history.concat([
{
cpu: state.cpu.percent,
ram: state.ram.percent,
down: state.network ? state.network.download : null,
up: state.network ? state.network.upload : null
}
]).slice(-60);
} catch (e) {
root.error = String(e);
}
}
}
stderr: StdioCollector {
id: errors
}
// Quickshell 0.3.1 metadata omits QProcess::ExitStatus.
// qmllint disable signal-handler-parameters
onExited: code => {
if (root.wanted) {
root.stale = true;
root.lastSample = 0;
root.nextStart = Date.now() + root.retryDelay;
root.retryDelay = Math.min(30000, root.retryDelay * 2);
root.error = errors.text.trim().slice(0, 300) || "Metrics collector stopped; retrying";
}
}
}
IpcHandler {
target: "metrics"
function status(): string {
return JSON.stringify({
running: process.running,
processId: process.processId,
retryDelay: root.retryDelay,
consumers: root.consumers,
samples: root.samples,
stale: root.stale,
error: root.error,
snapshot: root.snapshot
});
}
}
}
+66
View File
@@ -0,0 +1,66 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Networking
Singleton {
id: root
property var backend: Networking
readonly property var devices: backend.devices.values
readonly property var wifiDevices: devices.filter(d => d.type === DeviceType.Wifi)
readonly property var networks: devices.reduce((all, d) => all.concat(d.networks.values), [])
readonly property bool available: backend.backend === NetworkBackendType.NetworkManager && wifiDevices.length > 0
readonly property bool enabled: backend.wifiEnabled
readonly property string summary: networks.filter(n => n.connected).map(n => n.name).join(", ") || (devices.some(d => d.connected) ? "Connected" : "Disconnected")
property bool scanning: false
property var pending: null
property string error: ""
onScanningChanged: syncScan()
onWifiDevicesChanged: syncScan()
function syncScan() {
wifiDevices.forEach(d => d.scannerEnabled = scanning);
}
function toggle() {
if (!available || !backend.wifiHardwareEnabled)
return false;
error = "";
backend.wifiEnabled = !enabled;
return true;
}
function connectNetwork(network, password) {
if (!network || pending || network.stateChanging)
return false;
error = "";
pending = network;
timeout.restart();
if (network.connected)
network.disconnect();
else if (password)
network.connectWithPsk(password);
else
network.connect();
return true;
}
Connections {
target: root.pending
function onConnectionFailed(reason) {
root.error = ConnectionFailReason.toString(reason);
timeout.stop();
root.pending = null;
}
function onStateChanged() {
if (root.pending && !root.pending.stateChanging) {
timeout.stop();
root.pending = null;
}
}
}
Timer {
id: timeout
interval: 20000
onTriggered: {
root.error = "No connection confirmation received. Check the network manager.";
root.pending = null;
}
}
}
+476
View File
@@ -0,0 +1,476 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import "../core"
import "../compat/omarchy/Host" as OmarchyHost
import "../compat/noctalia/Host" as NoctaliaHost
// Installed shell plugins (Omarchy format, run through the compatibility layer
// in compat/omarchy). Plugins live in $XDG_DATA_HOME/glassMxrph/plugins and run
// unsandboxed inside the shell, as they do in Omarchy.
Singleton {
id: root
property var plugins: []
property bool loaded: false
property string error: ""
property var lastResult: ({})
readonly property bool busy: job.running
readonly property var enabledIds: ConfigService.ready ? ConfigService.data.plugins.enabled : []
property var queued: []
// Bar widget instances and service items, by plugin id (filled by the hosts).
property var widgets: ({})
property var services: ({})
// Noctalia panel windows by plugin id (for test drivers; no notifications).
readonly property var panelWindows: ({})
// The single open plugin popout (Omarchy's activePopout coordinator).
property var activePopout: null
function plugin(id) {
return plugins.find(p => p.id === id) || null;
}
function usable(id) {
const p = plugin(id);
return !!p && p.problems.length === 0;
}
function isEnabled(id) {
return enabledIds.includes(id) && usable(id);
}
function kinds(id) {
const p = plugin(id);
return p ? (p.kinds || p.manifest.kinds || []) : [];
}
function ecosystem(id) {
const p = plugin(id);
return p ? p.ecosystem : "";
}
// Plugin whose own settings screen Settings → Plugins should show open.
property string focusedSettings: ""
function entryUrl(id, kind) {
const p = plugin(id);
return p && isEnabled(id) ? (p.entryUrls[kind] || "") : "";
}
function title(id) {
const p = plugin(id);
if (!p)
return id;
const widget = p.ecosystem === "noctalia" ? {} : p.manifest.barWidget || {};
return widget.displayName || p.manifest.name || id;
}
// Enabled plugins offering a bar widget, as bar module ids.
readonly property var barModules: plugins.filter(p => isEnabled(p.id) && kinds(p.id).includes("bar-widget")).map(p => "plugin:" + p.id)
function schema(id) {
const p = plugin(id);
if (p && p.ecosystem === "noctalia")
return [];
return p && p.manifest.barWidget && Array.isArray(p.manifest.barWidget.schema) ? p.manifest.barWidget.schema : [];
}
// Widget settings: manifest defaults, schema defaults, then the user's values.
function widgetSettings(id, options) {
const p = plugin(id);
const out = Object.assign({}, p && p.manifest.barWidget ? p.manifest.barWidget.defaults || {} : {});
for (const field of schema(id))
if (out[field.key] === undefined && field.defaultValue !== undefined)
out[field.key] = field.defaultValue;
return Object.assign(out, options || {});
}
function call(args) {
if (job.running) {
queued = queued.concat([args]);
return;
}
job.command = ["python3", Quickshell.shellPath("helpers/plugins.py")].concat(args);
job.running = true;
}
function refresh() {
call(["list"]);
}
function install(source, commit, only) {
error = "";
call(["install", String(source).trim(), commit || "", only || ""]);
}
function remove(id) {
setEnabled(id, false);
// Drop its bar module from every layout.
const strip = list => list.filter(m => m.id !== "plugin:" + id);
ConfigService.setValue("bar.modules", strip(ConfigService.data.bar.modules));
const screens = Object.assign({}, ConfigService.data.bar.screens || {});
for (const name in screens)
screens[name] = Object.assign({}, screens[name], {
modules: strip(screens[name].modules)
});
ConfigService.setValue("bar.screens", screens);
call(["remove", id]);
}
// Calls an optional plugin function (plugin items are untyped).
function callIfPresent(target, name) {
if (target && typeof target[name] === "function")
target[name]();
}
function setEnabled(id, on) {
const list = enabledIds.filter(x => x !== id);
if (on && usable(id))
list.push(id);
ConfigService.setValue("plugins.enabled", list);
if (!on && activePopout && activePopout.moduleName === id)
closePopout();
}
// Adds an enabled plugin's bar widget to the shared bar layout.
function addToBar(id) {
const p = plugin(id);
if (!p || !isEnabled(id))
return false;
const moduleId = "plugin:" + id;
if (ConfigService.data.bar.modules.some(m => m.id === moduleId))
return false;
const section = (p.manifest.barWidget || {}).defaultSection;
return ConfigService.setValue("bar.modules", ConfigService.data.bar.modules.concat([
{
id: moduleId,
position: ["left", "center", "right"].includes(section) ? section : "right",
enabled: true
}
]));
}
// Widget registry, for summoning a plugin's panel by id.
function registerWidget(id, item) {
const next = Object.assign({}, widgets);
next[id] = (next[id] || []).filter(i => i !== item).concat([item]);
widgets = next;
}
function unregisterWidget(id, item) {
const next = Object.assign({}, widgets);
next[id] = (next[id] || []).filter(i => i !== item);
widgets = next;
}
function widgetFor(id) {
const list = widgets[id] || [];
const screen = ShellState.activeScreen();
return list.find(w => w.QsWindow && w.QsWindow.window && screen && w.QsWindow.window.screen === screen) || list[0] || null;
}
// Panel/overlay/menu plugins (PluginHost loads them when summoned).
property var openSurfaces: ({})
property var surfaces: ({})
property var pendingPayloads: ({})
function registerSurface(id, item) {
const next = Object.assign({}, surfaces);
if (item)
next[id] = item;
else
delete next[id];
surfaces = next;
if (item && pendingPayloads[id] !== undefined) {
const payload = pendingPayloads[id];
const rest = Object.assign({}, pendingPayloads);
delete rest[id];
pendingPayloads = rest;
if (typeof item.open === "function")
item.open(payload);
}
}
// Bar-widget plugins open their panel through the widget; other kinds are
// loaded on demand and receive open(payload), as in Omarchy.
function summon(id, payload) {
if (!isEnabled(id))
return false;
if (ecosystem(id) === "noctalia") {
const napi = noctaliaApi(id);
return !!napi && kinds(id).includes("panel") && napi.openPanel(ShellState.activeScreen(), napi.barWidget);
}
const w = widgetFor(id);
if (kinds(id).includes("bar-widget") && w && typeof w.open === "function") {
w.open();
return true;
}
if (!["panel", "overlay", "menu"].some(k => kinds(id).includes(k)))
return false;
const item = surfaces[id];
if (item && typeof item.open === "function") {
item.open(payload || "");
return true;
}
const pending = Object.assign({}, pendingPayloads);
pending[id] = payload || "";
pendingPayloads = pending;
const open = Object.assign({}, openSurfaces);
open[id] = true;
openSurfaces = open;
return true;
}
function hide(id) {
if (ecosystem(id) === "noctalia")
return !!noctaliaApis[id] && noctaliaApis[id].closePanel(null);
const w = widgetFor(id);
if (w && typeof w.close === "function") {
w.close();
return true;
}
const item = surfaces[id];
if (item && typeof item.close === "function") {
item.close();
return true;
}
return false;
}
function toggle(id, payload) {
if (ecosystem(id) === "noctalia") {
const napi = noctaliaApi(id);
return !!napi && kinds(id).includes("panel") && napi.togglePanel(ShellState.activeScreen(), napi.barWidget);
}
const w = widgetFor(id);
if (w && typeof w.toggle === "function") {
w.toggle();
return true;
}
const item = surfaces[id];
if (item && item.opened === true)
return hide(id);
return summon(id, payload);
}
// One plugin popout at a time; glassMxrph's own panels close too.
function requestPopout(owner) {
if (activePopout && activePopout !== owner && typeof activePopout.close === "function")
activePopout.close();
activePopout = owner;
ShellState.controlCenterOpen = false;
ShellState.dashboardOpen = false;
PopoutState.close();
TrayService.close();
}
function releasePopout(owner) {
if (activePopout === owner)
activePopout = null;
}
function closePopout() {
if (activePopout && typeof activePopout.close === "function")
activePopout.close();
activePopout = null;
}
// Scoped shell object for one plugin: it can reach its own service and
// panels and update its own widget settings, nothing else.
// Cached without change notifications: shellFor() is called from bindings.
readonly property var shellApis: ({})
function shellFor(id) {
if (shellApis[id])
return shellApis[id];
const owns = target => target === id || String(target).startsWith(id + ".") || String(target).startsWith(id + ":");
const api = shellApiComponent.createObject(root, {
pluginId: id,
_serviceLookup: target => owns(target) ? (root.services[id] || null) : null,
_firstPartyServiceLookup: target => null,
_summon: (target, payload) => owns(target) ? root.summon(id, payload) : false,
_hide: target => owns(target) ? root.hide(id) : false,
_toggle: (target, payload) => owns(target) ? root.toggle(id, payload) : false,
_isOpen: target => {
const w = root.widgetFor(id);
return owns(target) && !!w && w.opened === true;
},
_updateSettings: (target, settings) => owns(target) ? root.saveWidgetSettings(id, settings) : false
});
shellApis[id] = api;
return api;
}
function saveWidgetSettings(id, settings) {
const moduleId = "plugin:" + id;
const apply = list => list.map(m => m.id === moduleId ? Object.assign({}, m, {
options: Object.assign({}, m.options || {}, settings || {})
}) : m);
return ConfigService.setValue("bar.modules", apply(ConfigService.data.bar.modules));
}
Component {
id: shellApiComponent
OmarchyHost.PluginShellApi {}
}
// Noctalia v4: one pluginApi per plugin (cached without notifications).
readonly property var noctaliaApis: ({})
function noctaliaApi(id) {
if (noctaliaApis[id])
return noctaliaApis[id];
const p = plugin(id);
if (!p || p.ecosystem !== "noctalia")
return null;
const napi = noctaliaApiComponent.createObject(root, {
pluginId: id,
pluginDir: p.dir,
manifest: p.manifest,
_currentScreen: () => ShellState.activeScreen(),
_requestPanel: owner => root.requestPopout(owner)
});
noctaliaApis[id] = napi;
return napi;
}
Component {
id: noctaliaApiComponent
NoctaliaHost.PluginApi {}
}
Process {
id: job
stdout: StdioCollector {
onStreamFinished: {
try {
const result = JSON.parse(text);
root.lastResult = result;
root.plugins = result.plugins || [];
root.error = result.ok ? "" : (result.error || "Plugin command failed");
root.loaded = true;
} catch (e) {
root.error = String(e);
}
}
}
onRunningChanged: if (!running && root.queued.length) {
const next = root.queued[0];
root.queued = root.queued.slice(1);
root.call(next);
}
}
Component.onCompleted: refresh()
// Marketplace (plugins.omarchy.org) browsing; see helpers/marketplace.py.
property var market: ({
items: [],
total: 0,
categories: []
})
property string marketError: ""
property string marketQuery: ""
property string marketCategory: "all"
property string marketSort: "popular"
property bool marketVerifiedOnly: false
// "omarchy" (plugins.omarchy.org) or "noctalia" (noctalia-plugins registry).
property string marketSource: "omarchy"
onMarketSourceChanged: {
marketCategory = "all";
browse(false);
}
property bool marketAppend: false
readonly property bool marketBusy: browseJob.running
readonly property int marketPage: 30
function browse(more) {
marketAppend = !!more;
const offset = more ? market.items.length : 0;
browseJob.command = ["python3", Quickshell.shellPath("helpers/marketplace.py"), "search", marketQuery, marketCategory, marketSort, String(offset), String(marketPage), marketVerifiedOnly ? "true" : "false", marketSource];
browseJob.running = true;
}
// Installs the listing's plugin at the commit the marketplace validated.
function installListing(item) {
install(item.repo, item.commit, item.id);
}
function isInstalled(id) {
return !!plugin(id);
}
Timer {
id: browseDebounce
interval: 220
onTriggered: root.browse(false)
}
onMarketQueryChanged: browseDebounce.restart()
onMarketCategoryChanged: browse(false)
onMarketSortChanged: browse(false)
onMarketVerifiedOnlyChanged: browse(false)
Process {
id: browseJob
stdout: StdioCollector {
onStreamFinished: {
try {
const result = JSON.parse(text);
root.marketError = result.ok ? (result.warning || "") : (result.error || "Marketplace unavailable");
if (!result.ok)
return;
root.market = {
items: root.marketAppend ? root.market.items.concat(result.items) : result.items,
total: result.total,
categories: result.categories,
fetchedAt: result.fetchedAt
};
} catch (e) {
root.marketError = String(e);
}
}
}
}
Connections {
target: ShellState
function onControlCenterOpenChanged() {
if (ShellState.controlCenterOpen)
root.closePopout();
}
function onDashboardOpenChanged() {
if (ShellState.dashboardOpen)
root.closePopout();
}
function onLauncherOpenChanged() {
if (ShellState.launcherOpen)
root.closePopout();
}
function onSettingsOpenChanged() {
if (ShellState.settingsOpen)
root.closePopout();
}
}
IpcHandler {
target: "plugins"
function list(): string {
return JSON.stringify(root.plugins.map(p => ({
id: p.id,
name: p.manifest.name || p.id,
kinds: p.manifest.kinds || [],
enabled: root.isEnabled(p.id),
problems: p.problems
})));
}
function install(source: string): void {
root.install(source, "");
}
function remove(id: string): void {
root.remove(id);
}
function enable(id: string): void {
root.setEnabled(id, true);
}
function disable(id: string): void {
root.setEnabled(id, false);
}
function summon(id: string, payload: string): bool {
return root.summon(id, payload);
}
function toggle(id: string, payload: string): bool {
return root.toggle(id, payload);
}
// Marketplace search, as in the Browse tab.
function browse(query: string): void {
root.marketQuery = query;
}
function market(): string {
return JSON.stringify({
busy: root.marketBusy,
total: root.market.total,
error: root.marketError,
items: root.market.items.slice(0, 10).map(i => ({
id: i.id,
name: i.name,
kind: i.kind,
support: i.support,
verified: i.verified
}))
});
}
function status(): string {
return JSON.stringify({
loaded: root.loaded,
busy: root.busy,
error: root.error,
enabled: root.enabledIds,
barModules: root.barModules,
activePopout: root.activePopout ? (root.activePopout.moduleName || "?") : ""
});
}
}
}
+50
View File
@@ -0,0 +1,50 @@
pragma Singleton
import QtQuick
import Quickshell
import "../core"
Singleton {
id: root
property string pending: ""
function request(action) {
// The built-in lock screen needs no external locker.
if (action === "lock" && ConfigService.ready && ConfigService.data.lock.enabled) {
ShellState.requestLock();
return true;
}
if (!SystemService.state.power || !SystemService.state.power[action] || SystemService.acting)
return false;
if (["logout", "reboot", "shutdown"].includes(action)) {
pending = action;
return true;
}
if (!["lock", "suspend"].includes(action))
return false;
return SystemService.action("power", action, false);
}
function confirm() {
if (!pending || SystemService.acting)
return false;
const action = pending;
pending = "";
return SystemService.action("power", action, true);
}
function cancel() {
pending = "";
}
Connections {
target: ShellState
function onControlCenterOpenChanged() {
if (!ShellState.controlCenterOpen)
root.cancel();
}
function onSettingsPageChanged() {
root.cancel();
}
function onSettingsOpenChanged() {
if (!ShellState.settingsOpen)
root.cancel();
}
}
}
+38
View File
@@ -0,0 +1,38 @@
import QtQuick
import Quickshell
import Quickshell.Io
Process {
id: root
property string helper: "helpers/desktop.py"
property var request: ({})
signal finished(var request, var result)
function start(value) {
if (running)
return false;
request = JSON.parse(JSON.stringify(value));
command = ["python3", Quickshell.shellPath(helper), JSON.stringify(request)];
running = true;
return true;
}
stdout: StdioCollector {
id: output
}
stderr: StdioCollector {
id: errors
}
// Quickshell 0.3.1 omits QProcess::ExitStatus from its type metadata.
// qmllint disable signal-handler-parameters
onExited: code => {
let result;
try {
result = JSON.parse(output.text);
} catch (error) {
result = {
ok: false,
error: errors.text || "Provider did not return valid JSON (exit " + code + ")"
};
}
root.finished(root.request, result);
}
}
+21
View File
@@ -0,0 +1,21 @@
function editModule(modules,id,key,value) {return modules.map(m=>m.id===id?Object.assign({},m,{[key]:value}):m);}
function moveModule(modules,id,direction) {
const result=modules.slice(),item=result.find(m=>m.id===id);
if(!item)return result;
const lane=result.filter(m=>m.position===item.position),from=lane.findIndex(m=>m.id===id),target=lane[from+direction];
if(!target)return result;
const a=result.findIndex(m=>m.id===id),b=result.findIndex(m=>m.id===target.id);
[result[a],result[b]]=[result[b],result[a]];return result;
}
function removeModule(modules,id) {return modules.filter(m=>m.id!==id);}
// Move one stable module ID into a lane before another ID, or append to that lane.
function dropModule(modules,id,position,before) {
if (!["left","center","right"].includes(position) || before === id) return modules.slice();
const item=modules.find(m=>m.id===id);
if(!item)return modules.slice();
const result=modules.filter(m=>m.id!==id);
let index=result.findIndex(m=>m.id===before && m.position===position);
if(index<0) {index=result.length;for(let i=result.length-1;i>=0;i--)if(result[i].position===position){index=i+1;break;}}
result.splice(index,0,Object.assign({},item,{position:position}));
return result;
}
+87
View File
@@ -0,0 +1,87 @@
pragma Singleton
import QtQuick
import Quickshell
import "../core"
Singleton {
id: root
property string helper: "helpers/system.py"
property var state: ({})
property string error: ""
readonly property bool busy: job.running
// A user action is in flight. Controls lock on this, not on busy: locking
// them for every background status poll flickered them every five seconds.
readonly property bool acting: (job.running && job.request.op === "action") || queued !== null
property var queued: null
readonly property var features: {
if (!ConfigService.ready)
return [];
if (ShellState.controlCenterOpen)
return ConfigService.data.controlCenter.modules.filter(m => m.enabled && ["brightness", "nightLight", "dnd", "profiles", "power"].includes(m.id)).map(m => m.id);
if (ShellState.dashboardOpen)
return ["power"];
if (!ShellState.settingsOpen)
return [];
if (ShellState.settingsPage === "displays")
return ["brightness", "nightLight"];
if (ShellState.settingsPage === "notifications")
return ["dnd"];
if (ShellState.settingsPage === "power")
return ["power", "profiles"];
return [];
}
readonly property bool observed: features.length > 0
onFeaturesChanged: if (observed)
refresh()
onObservedChanged: if (observed)
refresh()
function refresh() {
if (ConfigService.ready && !busy)
job.start({
op: "status",
features: features,
options: ConfigService.data.system
});
}
function action(kind, value, confirmed) {
if (acting || !ConfigService.ready)
return false;
error = "";
const request = {
op: "action",
action: kind,
value: value,
confirmed: confirmed === true,
options: ConfigService.data.system
};
// A status poll is running: run the action as soon as it finishes.
if (busy) {
queued = request;
return true;
}
return job.start(request);
}
ProviderJob {
id: job
helper: root.helper
onFinished: (request, result) => {
if (result.ok) {
root.state = Object.assign({}, root.state, result.state);
if (request.op === "action")
root.error = "";
} else
root.error = result.error || "System request failed";
if (root.queued) {
const next = root.queued;
root.queued = null;
job.start(next);
}
}
}
Timer {
interval: 5000
repeat: true
running: root.observed
onTriggered: root.refresh()
}
}
+135
View File
@@ -0,0 +1,135 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Services.SystemTray
import "../core"
Singleton {
id: root
readonly property var items: SystemTray.items.values
readonly property var options: ConfigService.ready ? ConfigService.data.tray : ({
enabled: false,
hoverMenus: true,
hoverDelay: 400,
iconSize: 20,
spacing: 8,
background: "pill"
})
property var currentItem: null
property var anchorItem: null
property bool opened: false
property bool closeOnLeave: false
property var windows: []
// Bar windows, for test drivers and hover hand-off.
property var barWindows: []
property var hoveredWindows: []
property var icons: []
// Only click-opened menus grab keyboard focus; hover menus never steal it.
readonly property bool grabbing: opened && !closeOnLeave
readonly property bool pointerInside: (anchorItem && anchorItem.pointerInside) || hoveredWindows.length > 0
onPointerInsideChanged: updateDismissal()
onItemsChanged: if (currentItem && !items.includes(currentItem))
close()
onCurrentItemChanged: if (!currentItem)
close()
onOptionsChanged: if (!options.enabled)
close()
function registerIcon(icon) {
icons = icons.concat([icon]);
}
function unregisterIcon(icon) {
if (anchorItem === icon)
close();
icons = icons.filter(i => i !== icon);
}
function registerBar(window) {
barWindows = barWindows.concat([window]);
}
function unregisterBar(window) {
barWindows = barWindows.filter(w => w !== window);
}
function registerWindow(window) {
windows = windows.concat([window]);
}
function unregisterWindow(window) {
windows = windows.filter(w => w !== window);
setHovered(window, false);
}
function setHovered(window, inside) {
hoveredWindows = hoveredWindows.filter(w => w !== window);
if (inside)
hoveredWindows = hoveredWindows.concat([window]);
}
function updateDismissal() {
if (opened && closeOnLeave && !pointerInside)
leaveTimer.restart();
else
leaveTimer.stop();
}
function open(item, icon, hover) {
if (!options.enabled || !item || !item.hasMenu || !icon)
return false;
ShellState.controlCenterOpen = false;
ShellState.launcherOpen = false;
ShellState.settingsOpen = false;
currentItem = item;
anchorItem = icon;
closeOnLeave = hover;
opened = true;
updateDismissal();
return true;
}
function close() {
opened = false;
leaveTimer.stop();
}
function openById(id, monitor) {
const icon = icons.find(i => i.trayItem && i.trayItem.id === id && (!monitor || i.barScreen.name === monitor));
return icon ? open(icon.trayItem, icon, false) : false;
}
Connections {
target: ShellState
function onControlCenterOpenChanged() {
if (ShellState.controlCenterOpen)
root.close();
}
function onSettingsOpenChanged() {
if (ShellState.settingsOpen)
root.close();
}
function onLauncherOpenChanged() {
if (ShellState.launcherOpen)
root.close();
}
}
Timer {
id: leaveTimer
interval: 300
onTriggered: if (!root.pointerInside)
root.close()
}
IpcHandler {
target: "tray"
function open(id: string, monitor: string): bool {
return root.openById(id, monitor);
}
function close(): void {
root.close();
}
function status(): string {
return JSON.stringify({
opened: root.opened,
grabbing: root.grabbing,
currentId: root.currentItem ? root.currentItem.id : "",
items: root.items.map(i => ({
id: i.id,
title: i.title,
hasMenu: i.hasMenu,
onlyMenu: i.onlyMenu
})),
menus: root.windows.filter(w => w.visible).map(w => w.snapshot())
});
}
}
}
+159
View File
@@ -0,0 +1,159 @@
pragma Singleton
import QtQuick
import Quickshell
import Quickshell.Io
import "../core"
Singleton {
id: root
property var images: []
property var observed: ({})
property string backend: "none"
property string error: ""
property string notice: ""
// "all" applies to every connected output in turn; "primary" or an output name targets one.
property string selectedMonitor: "all"
property var queue: []
readonly property var output: ScreenService.resolve(selectedMonitor)
readonly property string monitor: output ? output.name : ""
readonly property var paletteOutput: ConfigService.ready ? ScreenService.resolve(ConfigService.data.wallpaper.paletteMonitor) : null
readonly property string palettePath: paletteOutput ? (observed[paletteOutput.name] || (ConfigService.ready ? ConfigService.data.wallpaper.byMonitor[paletteOutput.name] : "") || "") : ""
readonly property string currentPath: observed[monitor] || (ConfigService.ready ? ConfigService.data.wallpaper.byMonitor[monitor] : "") || ""
property var nativePending: null
readonly property bool busy: applyJob.running || nativePending !== null || queue.length > 0
readonly property bool scanning: scanJob.running
function request(action, target) {
const name = target || monitor;
return {
action: action,
monitor: name,
backend: ConfigService.data.wallpaper.backend,
command: ConfigService.data.wallpaper.command,
current: observed[name] || ConfigService.data.wallpaper.byMonitor[name] || ""
};
}
function refresh() {
if (ConfigService.ready && monitor)
probeJob.start(request("provider"));
}
function scan() {
if (ConfigService.ready)
scanJob.start({
action: "scan",
directories: ConfigService.data.wallpaper.directories
});
}
function changed(output, path) {
const next = Object.assign({}, observed);
next[output] = path;
observed = next;
}
function apply(path) {
const outputs = selectedMonitor === "all" ? Quickshell.screens.map(s => s.name) : [monitor];
if (!ConfigService.ready || !ConfigService.writable || !outputs.length || !outputs[0] || busy)
return false;
error = "";
queue = outputs.slice(1).map(name => ({
path: path,
monitor: name
}));
const req = request("apply", outputs[0]);
req.path = path;
return applyJob.start(req);
}
// Starts the next queued output once the previous one has fully applied.
function applyNext() {
if (!queue.length)
return;
const next = queue[0];
const req = request("apply", next.monitor);
req.path = next.path;
queue = queue.slice(1);
applyJob.start(req);
}
onMonitorChanged: refresh()
ProviderJob {
id: probeJob
onFinished: (request, result) => {
if (!result.ok) {
root.error = result.error;
return;
}
root.backend = result.backend;
root.notice = result.notice || "";
if (result.current)
root.changed(request.monitor, ConfigService.data.wallpaper.providerPaths[request.monitor] === result.current ? (ConfigService.data.wallpaper.byMonitor[request.monitor] || result.current) : result.current);
}
}
ProviderJob {
id: scanJob
onFinished: (request, result) => {
if (result.ok) {
root.images = result.images;
root.notice = (result.notice || "") + (result.limited ? " Showing the first 1,000 images." : "");
} else
root.error = result.error;
}
}
ProviderJob {
id: applyJob
onFinished: (request, result) => {
if (!result.ok) {
root.error = result.error;
root.queue = [];
return;
}
if(result.backend === "native") root.nativePending = {request:request,result:result};
else root.finishApply(request,result);
}
}
function finishApply(request,result) {
const next = Object.assign({}, ConfigService.data.wallpaper.byMonitor);
next[request.monitor] = result.path;
ConfigService.setValue("wallpaper.byMonitor", next);
const providerPaths = Object.assign({}, ConfigService.data.wallpaper.providerPaths);
providerPaths[request.monitor] = result.providerPath;
ConfigService.setValue("wallpaper.providerPaths", providerPaths);
root.backend = result.backend;
root.changed(request.monitor, result.path);
root.error = "";
ConfigService.setValue("wallpaper.history",[result.path].concat(ConfigService.data.wallpaper.history.filter(p=>p!==result.path)).slice(0,50));
Qt.callLater(root.applyNext);
}
Image {
visible:false
asynchronous:true
sourceSize:Qt.size(32,32)
source:root.nativePending ? root.nativePending.result.url : ""
onStatusChanged: {
if(!root.nativePending)return;
if(status===Image.Ready) {const pending=root.nativePending;root.nativePending=null;root.finishApply(pending.request,pending.result);}
else if(status===Image.Error) {root.error="Could not decode this wallpaper";root.nativePending=null;root.queue=[];}
}
}
IpcHandler {
target: "wallpaper"
function picker(): void {ShellState.openWallpaperPicker();}
function changed(monitor: string, path: string): void {
root.changed(monitor, path);
}
function refresh(): void {
root.refresh();
root.scan();
}
function apply(path: string): bool {
return root.apply(path);
}
function status(): string {
return JSON.stringify({
backend: root.backend,
current: root.currentPath,
palettePath: root.palettePath,
busy: root.busy,
images: root.images.length,
error: root.error,
notice: root.notice
});
}
}
}
+67
View File
@@ -0,0 +1,67 @@
// Pure helpers for desktop widgets: item edits, move snapping and resizing.
// Rects are {x, y, w, h} in output-local logical pixels.
function newId(items) {
let id;
do id = "w-" + Date.now().toString(36) + "-" + Math.floor(Math.random() * 1296).toString(36);
while (items.some(i => i.id === id));
return id;
}
function addItem(items, item) {return items.concat([item]);}
function updateItem(items, id, patch) {return items.map(i => i.id === id ? Object.assign({}, i, patch) : i);}
function removeItem(items, id) {return items.filter(i => i.id !== id);}
function clampRect(r, bounds) {
const w = Math.min(r.w, bounds.w), h = Math.min(r.h, bounds.h);
return {x: Math.max(0, Math.min(bounds.w - w, r.x)), y: Math.max(0, Math.min(bounds.h - h, r.y)), w: w, h: h};
}
// Snap a moved rect to the grid, or to screen edges/centre and other widgets'
// edges/centres within `threshold`. Returns the rect plus guide lines to draw.
function snapMove(r, others, bounds, grid, threshold) {
let x = r.x, y = r.y;
const guides = {x: [], y: []};
if (grid > 0) {
x = Math.round(x / grid) * grid;
y = Math.round(y / grid) * grid;
} else {
const xs = [0, bounds.w / 2, bounds.w], ys = [0, bounds.h / 2, bounds.h];
for (const o of others) {
xs.push(o.x, o.x + o.w / 2, o.x + o.w);
ys.push(o.y, o.y + o.h / 2, o.y + o.h);
}
const best = (start, size, lines) => {
let found = null;
for (const line of lines)
for (const offset of [0, size / 2, size]) {
const delta = line - (start + offset);
if (Math.abs(delta) <= threshold && (!found || Math.abs(delta) < Math.abs(found.delta)))
found = {delta: delta, line: line};
}
return found;
};
const bx = best(x, r.w, xs), by = best(y, r.h, ys);
if (bx) {x += bx.delta; guides.x.push(bx.line);}
if (by) {y += by.delta; guides.y.push(by.line);}
}
const c = clampRect({x: x, y: y, w: r.w, h: r.h}, bounds);
return {x: c.x, y: c.y, w: c.w, h: c.h, guides: guides};
}
// Resize from `start` by a pointer delta on the given edges ({left,right,top,bottom}),
// honouring minimum/maximum sizes, the grid and the output bounds.
function resizeRect(start, dx, dy, edges, limits, bounds, grid) {
const snap = v => grid > 0 ? Math.round(v / grid) * grid : v;
let left = start.x, top = start.y, right = start.x + start.w, bottom = start.y + start.h;
if (edges.left) left = snap(Math.max(0, start.x + dx));
if (edges.right) right = snap(Math.min(bounds.w, start.x + start.w + dx));
if (edges.top) top = snap(Math.max(0, start.y + dy));
if (edges.bottom) bottom = snap(Math.min(bounds.h, start.y + start.h + dy));
const fit = (a, b, lo, hi, moveA) => {
const size = Math.max(lo, Math.min(hi, b - a));
return moveA ? [b - size, b] : [a, a + size];
};
[left, right] = fit(left, right, limits.minW, limits.maxW, !!edges.left);
[top, bottom] = fit(top, bottom, limits.minH, limits.maxH, !!edges.top);
return clampRect({x: left, y: top, w: right - left, h: bottom - top}, bounds);
}
+17
View File
@@ -0,0 +1,17 @@
singleton ConfigService 1.0 ConfigService.qml
singleton TrayService 1.0 TrayService.qml
singleton ApplicationsService 1.0 ApplicationsService.qml
singleton HyprlandService 1.0 HyprlandService.qml
ProviderJob 1.0 ProviderJob.qml
singleton WallpaperService 1.0 WallpaperService.qml
singleton MediaService 1.0 MediaService.qml
singleton CavaService 1.0 CavaService.qml
singleton AudioService 1.0 AudioService.qml
singleton NetworkService 1.0 NetworkService.qml
singleton BluetoothService 1.0 BluetoothService.qml
singleton SystemService 1.0 SystemService.qml
singleton PowerService 1.0 PowerService.qml
singleton MetricsService 1.0 MetricsService.qml
singleton GlassService 1.0 GlassService.qml
singleton EasyEffectsService 1.0 EasyEffectsService.qml
singleton PluginService 1.0 PluginService.qml