Settings → Notch switches it on. The bar becomes left and right islands with a notch at the top centre. Super+C, Super+X and a click on the notch open a three-column panel: dashboard pages on the left (Media, Performance, Calendar; the wheel switches them), the Control Center tiles and weather in the middle, and notifications on the right. The Performance card opens the full "Your computer" view. The launcher drops out of the notch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
480 lines
18 KiB
QML
480 lines
18 KiB
QML
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)
|
|
// Enabled plugins offering a Control Center widget, as Control Center module ids.
|
|
readonly property var controlModules: plugins.filter(p => isEnabled(p.id) && kinds(p.id).includes("control-center-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.notchOpen = 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 || "?") : ""
|
|
});
|
|
}
|
|
}
|
|
}
|