This is a projection, not a development branch. The tree above was constructed from the internal source named below under a manifest that decides which paths may leave, then scanned as a whole tree rather than as a series of patches, and only then published. Public history starts here because the history before it was not admissible, and neither was the tree. What used to stand in this repository included a rescue copy of another machine, a directory of phone handoffs, deployment wired to one house, and a submodule pointing at a forge no stranger can reach. None of that was ever the product. It stays in the private forge, which is allowed to hold the whole working organism, and this is what was deliberately sent out instead. Three mechanisms produced this tree, in decreasing order of trust. A top-level path the manifest does not name never arrives at all, which is the one that catches directories nobody has thought of yet. Named internal files inside admitted roots are dropped. A short, reviewed table replaces deployment defaults that a public build must not carry -- an endpoint aimed at one LAN, a VPN profile belonging to one phone, packaging built from one checkout path. Everything after this commit is an ordinary publication with the same three trailers, so a force push stops being routine and starts meaning that something deliberate happened. The trailers bind the projection to its source without pretending the public SHA is the private one: same lineage, different tree, and the record says so. Source-Sha: 8f27b1e76a8fef560a336aba18e6990713ff1047 Policy-Sha: 6b261d2f3e6e1fb19874846ba4bb1dfe15565d25b8618c1c1afba0419c101d27 Tree-Digest: 18ec3563c5e5ef9a414993a9f6734b251ff9ed3cd56eebdd6cac01e45c6e3067
226 lines
7.5 KiB
QML
226 lines
7.5 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import Quickshell.Wayland
|
|
import Quickshell.Hyprland
|
|
|
|
/**
|
|
* Provides access to some Hyprland data not available in Quickshell.Hyprland.
|
|
*/
|
|
Singleton {
|
|
id: root
|
|
property var windowList: []
|
|
property var addresses: []
|
|
property var windowByAddress: ({})
|
|
property var workspaces: []
|
|
property var workspaceIds: []
|
|
property var workspaceById: ({})
|
|
property var activeWorkspace: null
|
|
property var activeWindow: null
|
|
property var monitors: []
|
|
|
|
// Parse hyprctl's JSON, or keep what we had.
|
|
//
|
|
// Every collector below did a bare `JSON.parse()` on the process output.
|
|
// That is fine while Hyprland is the compositor and a hard error the
|
|
// moment it is not: under viewtop there is no `hyprctl`, the output is
|
|
// empty, and each collector threw a SyntaxError on every refresh — six
|
|
// exceptions per pass, forever, drowning the log the shell is diagnosed
|
|
// from.
|
|
//
|
|
// Absence is a state, not a failure. `HYPRLAND_INSTANCE_SIGNATURE` unset
|
|
// means "another compositor", and the honest answer is to keep the last
|
|
// known value and say so once — the same distinction
|
|
// DEVICE-STATE-MACHINE.md §10 draws between "no evidence" and "evidence
|
|
// says nothing".
|
|
property bool available: true
|
|
function parseOrKeep(text, fallback, what) {
|
|
if (!text || text.trim().length === 0) {
|
|
if (root.available) {
|
|
root.available = false;
|
|
console.log("[HyprlandData] no hyprctl output for", what,
|
|
"— assuming another compositor; monitor geometry comes from `screen`");
|
|
}
|
|
return fallback;
|
|
}
|
|
try {
|
|
const parsed = JSON.parse(text);
|
|
if (!root.available) {
|
|
root.available = true;
|
|
console.log("[HyprlandData] hyprctl is answering again");
|
|
}
|
|
return parsed;
|
|
} catch (e) {
|
|
// Latched like the empty case: `hyprctl` missing does not always
|
|
// mean *empty* output — a shell that prints an error to stdout
|
|
// lands here instead, and it lands here on every refresh. One line
|
|
// per edge, not four per pass. Same rule §10 applies to a sensor
|
|
// that has gone quiet: say it when it changes, not when it repeats.
|
|
if (root.available) {
|
|
root.available = false;
|
|
console.log("[HyprlandData]", what, "is unparseable —",
|
|
"assuming another compositor; monitor geometry comes from `screen`:", e);
|
|
}
|
|
return fallback;
|
|
}
|
|
}
|
|
|
|
property var layers: ({})
|
|
|
|
// Convenient stuff
|
|
|
|
function toplevelsForWorkspace(workspace) {
|
|
return ToplevelManager.toplevels.values.filter(toplevel => {
|
|
const address = `0x${toplevel.HyprlandToplevel?.address}`;
|
|
var win = HyprlandData.windowByAddress[address];
|
|
return win?.workspace?.id === workspace;
|
|
})
|
|
}
|
|
|
|
function hyprlandClientsForWorkspace(workspace) {
|
|
return root.windowList.filter(win => win.workspace.id === workspace);
|
|
}
|
|
|
|
function clientForToplevel(toplevel) {
|
|
if (!toplevel || !toplevel.HyprlandToplevel) {
|
|
return null;
|
|
}
|
|
const address = `0x${toplevel?.HyprlandToplevel?.address}`;
|
|
return root.windowByAddress[address];
|
|
}
|
|
|
|
// Internals
|
|
|
|
function updateWindows() {
|
|
getClients.running = true;
|
|
getActiveWindow.running = true;
|
|
}
|
|
|
|
function updateLayers() {
|
|
getLayers.running = true;
|
|
}
|
|
|
|
function updateMonitors() {
|
|
getMonitors.running = true;
|
|
}
|
|
|
|
function updateWorkspaces() {
|
|
getWorkspaces.running = true;
|
|
getActiveWorkspace.running = true;
|
|
}
|
|
|
|
function updateAll() {
|
|
updateWindows();
|
|
updateMonitors();
|
|
updateLayers();
|
|
updateWorkspaces();
|
|
}
|
|
|
|
function biggestWindowForWorkspace(workspaceId) {
|
|
const windowsInThisWorkspace = HyprlandData.windowList.filter(w => w.workspace.id == workspaceId);
|
|
return windowsInThisWorkspace.reduce((maxWin, win) => {
|
|
const maxArea = (maxWin?.size?.[0] ?? 0) * (maxWin?.size?.[1] ?? 0);
|
|
const winArea = (win?.size?.[0] ?? 0) * (win?.size?.[1] ?? 0);
|
|
return winArea > maxArea ? win : maxWin;
|
|
}, null);
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
updateAll();
|
|
}
|
|
|
|
Connections {
|
|
target: Hyprland
|
|
|
|
function onRawEvent(event) {
|
|
// console.log("Hyprland raw event:", event.name);
|
|
if (["openlayer", "closelayer", "screencast"].includes(event.name)) return;
|
|
updateAll()
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: getClients
|
|
command: ["hyprctl", "clients", "-j"]
|
|
stdout: StdioCollector {
|
|
id: clientsCollector
|
|
onStreamFinished: {
|
|
root.windowList = root.parseOrKeep(clientsCollector.text, [], "data")
|
|
let tempWinByAddress = {};
|
|
for (var i = 0; i < root.windowList.length; ++i) {
|
|
var win = root.windowList[i];
|
|
tempWinByAddress[win.address] = win;
|
|
}
|
|
root.windowByAddress = tempWinByAddress;
|
|
root.addresses = root.windowList.map(win => win.address);
|
|
}
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: getActiveWindow
|
|
command: ["hyprctl", "activewindow", "-j"]
|
|
stdout: StdioCollector {
|
|
id: activeWindowCollector
|
|
onStreamFinished: {
|
|
root.activeWindow = root.parseOrKeep(activeWindowCollector.text, root.activeWindow, "activewindow")
|
|
}
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: getMonitors
|
|
command: ["hyprctl", "monitors", "-j"]
|
|
stdout: StdioCollector {
|
|
id: monitorsCollector
|
|
onStreamFinished: {
|
|
root.monitors = root.parseOrKeep(monitorsCollector.text, root.monitors, "monitors");
|
|
}
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: getLayers
|
|
command: ["hyprctl", "layers", "-j"]
|
|
stdout: StdioCollector {
|
|
id: layersCollector
|
|
onStreamFinished: {
|
|
root.layers = root.parseOrKeep(layersCollector.text, root.layers, "layers");
|
|
}
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: getWorkspaces
|
|
command: ["hyprctl", "workspaces", "-j"]
|
|
stdout: StdioCollector {
|
|
id: workspacesCollector
|
|
onStreamFinished: {
|
|
var rawWorkspaces = root.parseOrKeep(workspacesCollector.text, root.workspaces, "workspaces");
|
|
// Filter out invalid workspace ids (e.g. lock-screen temp workspace 2147483647 - N)
|
|
root.workspaces = rawWorkspaces.filter(ws => ws.id >= 1 && ws.id <= 100);
|
|
let tempWorkspaceById = {};
|
|
for (var i = 0; i < root.workspaces.length; ++i) {
|
|
var ws = root.workspaces[i];
|
|
tempWorkspaceById[ws.id] = ws;
|
|
}
|
|
root.workspaceById = tempWorkspaceById;
|
|
root.workspaceIds = root.workspaces.map(ws => ws.id);
|
|
}
|
|
}
|
|
}
|
|
|
|
Process {
|
|
id: getActiveWorkspace
|
|
command: ["hyprctl", "activeworkspace", "-j"]
|
|
stdout: StdioCollector {
|
|
id: activeWorkspaceCollector
|
|
onStreamFinished: {
|
|
root.activeWorkspace = root.parseOrKeep(activeWorkspaceCollector.text, root.activeWorkspace, "activeworkspace");
|
|
}
|
|
}
|
|
}
|
|
}
|