mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-16 08:14:03 -04:00
deprecation notice to plugin compatibility shims - When qml-common became a thing, we left qs.Widgets shims in place for plugin compatibility - It's annoying to need to maintain them when qml-common has any change, add a warning so we can safely deprecate them in the future - One shot rename the common stuff to D to make it shorter and nicer to write
64 lines
1.6 KiB
QML
64 lines
1.6 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import qs.Common
|
|
import qs.Services
|
|
import qs.DCommon.Common as DCommon
|
|
|
|
Singleton {
|
|
id: root
|
|
readonly property var log: Log.scoped("UmbrielService")
|
|
|
|
readonly property string socketPath: Quickshell.env("UMBRIEL_SOCKET")
|
|
|
|
property bool active: false
|
|
property var workspaces: []
|
|
property var windows: []
|
|
readonly property string focusedOutput: workspaces.find(ws => ws.focused)?.output ?? ""
|
|
|
|
DCommon.DSocket {
|
|
path: root.socketPath
|
|
connected: root.active && root.socketPath !== ""
|
|
|
|
onConnectionStateChanged: {
|
|
if (linkUp)
|
|
send({
|
|
"cmd": "subscribe",
|
|
"events": ["workspaces", "windows"]
|
|
});
|
|
}
|
|
|
|
parser: SplitParser {
|
|
onRead: line => root._handleEvent(line)
|
|
}
|
|
}
|
|
|
|
function _handleEvent(line) {
|
|
let message;
|
|
try {
|
|
message = JSON.parse(line);
|
|
} catch (e) {
|
|
log.warn("Failed to parse event:", e);
|
|
return;
|
|
}
|
|
switch (message.event) {
|
|
case "workspaces":
|
|
workspaces = message.data;
|
|
return;
|
|
case "windows":
|
|
windows = message.data;
|
|
return;
|
|
}
|
|
}
|
|
|
|
function action(name) {
|
|
Proc.runCommand(null, ["umbriel", "msg", name], (output, exitCode) => {
|
|
if (exitCode !== 0)
|
|
log.warn("umbriel msg", name, "exited with", exitCode);
|
|
}, 0);
|
|
}
|
|
}
|