mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-06 13:38:28 -04:00
Compare commits
1 Commits
stable
...
c128793239
| Author | SHA1 | Date | |
|---|---|---|---|
| c128793239 |
@@ -11,7 +11,7 @@ Singleton {
|
|||||||
id: root
|
id: root
|
||||||
readonly property var log: Log.scoped("DMSService")
|
readonly property var log: Log.scoped("DMSService")
|
||||||
|
|
||||||
property bool dmsAvailable: false
|
readonly property bool dmsAvailable: isConnected
|
||||||
property var capabilities: []
|
property var capabilities: []
|
||||||
property int apiVersion: 0
|
property int apiVersion: 0
|
||||||
property string cliVersion: ""
|
property string cliVersion: ""
|
||||||
@@ -21,7 +21,7 @@ Singleton {
|
|||||||
property var availableThemes: []
|
property var availableThemes: []
|
||||||
property var installedThemes: []
|
property var installedThemes: []
|
||||||
property bool isConnected: false
|
property bool isConnected: false
|
||||||
property bool isConnecting: false
|
readonly property bool isConnecting: requestSocket.connected && !requestSocket.linkUp
|
||||||
property bool subscribeConnected: false
|
property bool subscribeConnected: false
|
||||||
|
|
||||||
readonly property string socketPath: Quickshell.env("DMS_SOCKET")
|
readonly property string socketPath: Quickshell.env("DMS_SOCKET")
|
||||||
@@ -72,9 +72,10 @@ Singleton {
|
|||||||
property var activeSubscriptions: ["network", "network.credentials", "loginctl", "freedesktop", "freedesktop.screensaver", "gamma", "theme.auto", "wallpaper", "bluetooth", "bluetooth.pairing", "brightness", "wlroutput", "evdev", "browser", "dbus", "clipboard", "sysupdate"]
|
property var activeSubscriptions: ["network", "network.credentials", "loginctl", "freedesktop", "freedesktop.screensaver", "gamma", "theme.auto", "wallpaper", "bluetooth", "bluetooth.pairing", "brightness", "wlroutput", "evdev", "browser", "dbus", "clipboard", "sysupdate"]
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (socketPath && socketPath.length > 0) {
|
if (!socketPath || socketPath.length === 0)
|
||||||
detectUpdateCommand();
|
return;
|
||||||
}
|
detectUpdateCommand();
|
||||||
|
requestSocket.connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectUpdateCommand() {
|
function detectUpdateCommand() {
|
||||||
@@ -82,12 +83,6 @@ Singleton {
|
|||||||
checkAurHelper.running = true;
|
checkAurHelper.running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startSocketConnection() {
|
|
||||||
if (socketPath && socketPath.length > 0) {
|
|
||||||
testProcess.running = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: checkAurHelper
|
id: checkAurHelper
|
||||||
command: ["sh", "-c", "command -v paru || command -v yay"]
|
command: ["sh", "-c", "command -v paru || command -v yay"]
|
||||||
@@ -105,7 +100,6 @@ Singleton {
|
|||||||
} else {
|
} else {
|
||||||
updateCommand = "dms update";
|
updateCommand = "dms update";
|
||||||
checkingUpdateCommand = false;
|
checkingUpdateCommand = false;
|
||||||
startSocketConnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,7 +108,6 @@ Singleton {
|
|||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
updateCommand = "dms update";
|
updateCommand = "dms update";
|
||||||
checkingUpdateCommand = false;
|
checkingUpdateCommand = false;
|
||||||
startSocketConnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +128,6 @@ Singleton {
|
|||||||
updateCommand = "dms update";
|
updateCommand = "dms update";
|
||||||
}
|
}
|
||||||
checkingUpdateCommand = false;
|
checkingUpdateCommand = false;
|
||||||
startSocketConnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,52 +135,27 @@ Singleton {
|
|||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
updateCommand = "dms update";
|
updateCommand = "dms update";
|
||||||
checkingUpdateCommand = false;
|
checkingUpdateCommand = false;
|
||||||
startSocketConnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
|
||||||
id: testProcess
|
|
||||||
command: ["test", "-S", root.socketPath]
|
|
||||||
|
|
||||||
onExited: exitCode => {
|
|
||||||
if (exitCode === 0) {
|
|
||||||
root.dmsAvailable = true;
|
|
||||||
connectSocket();
|
|
||||||
} else {
|
|
||||||
root.dmsAvailable = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function connectSocket() {
|
|
||||||
if (!dmsAvailable || isConnected || isConnecting) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isConnecting = true;
|
|
||||||
requestSocket.connected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
DankSocket {
|
DankSocket {
|
||||||
id: requestSocket
|
id: requestSocket
|
||||||
path: root.socketPath
|
path: root.socketPath
|
||||||
connected: false
|
connected: false
|
||||||
|
|
||||||
onConnectionStateChanged: {
|
onConnectionStateChanged: {
|
||||||
if (connected) {
|
if (linkUp) {
|
||||||
root.isConnected = true;
|
root.isConnected = true;
|
||||||
root.isConnecting = false;
|
|
||||||
root.connectionStateChanged();
|
root.connectionStateChanged();
|
||||||
subscribeSocket.connected = true;
|
subscribeSocket.connected = true;
|
||||||
} else {
|
return;
|
||||||
root.isConnected = false;
|
|
||||||
root.isConnecting = false;
|
|
||||||
root.apiVersion = 0;
|
|
||||||
root.capabilities = [];
|
|
||||||
root.connectionStateChanged();
|
|
||||||
}
|
}
|
||||||
|
root.isConnected = false;
|
||||||
|
root.apiVersion = 0;
|
||||||
|
root.capabilities = [];
|
||||||
|
root.failPendingRequests();
|
||||||
|
root.connectionStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
parser: SplitParser {
|
parser: SplitParser {
|
||||||
@@ -219,10 +186,10 @@ Singleton {
|
|||||||
connected: false
|
connected: false
|
||||||
|
|
||||||
onConnectionStateChanged: {
|
onConnectionStateChanged: {
|
||||||
root.subscribeConnected = connected;
|
root.subscribeConnected = linkUp;
|
||||||
if (connected) {
|
if (!linkUp)
|
||||||
sendSubscribeRequest();
|
return;
|
||||||
}
|
sendSubscribeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
parser: SplitParser {
|
parser: SplitParser {
|
||||||
@@ -446,10 +413,20 @@ Singleton {
|
|||||||
|
|
||||||
function handleResponse(response) {
|
function handleResponse(response) {
|
||||||
const callback = pendingRequests[response.id];
|
const callback = pendingRequests[response.id];
|
||||||
|
if (!callback)
|
||||||
|
return;
|
||||||
|
delete pendingRequests[response.id];
|
||||||
|
callback(response);
|
||||||
|
}
|
||||||
|
|
||||||
if (callback) {
|
function failPendingRequests() {
|
||||||
delete pendingRequests[response.id];
|
const pending = pendingRequests;
|
||||||
callback(response);
|
pendingRequests = {};
|
||||||
|
clipboardRequestIds = {};
|
||||||
|
for (const id in pending) {
|
||||||
|
pending[id]({
|
||||||
|
"error": "not connected to DMS socket"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user