1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

sway: add support for sway

This commit is contained in:
bbedward
2025-10-29 15:08:11 -04:00
parent 7b26692c8e
commit c87fa0de5e
12 changed files with 212 additions and 26 deletions

View File

@@ -13,10 +13,12 @@ Singleton {
property bool isHyprland: false
property bool isNiri: false
property bool isDwl: false
property bool isSway: false
property string compositor: "unknown"
readonly property string hyprlandSignature: Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE")
readonly property string niriSocket: Quickshell.env("NIRI_SOCKET")
readonly property string swaySocket: Quickshell.env("SWAYSOCK")
property bool useNiriSorting: isNiri && NiriService
property var sortedToplevels: sortedToplevelsCache
@@ -363,6 +365,7 @@ Singleton {
isHyprland = true
isNiri = false
isDwl = false
isSway = false
compositor = "hyprland"
console.info("CompositorService: Detected Hyprland")
try {
@@ -377,28 +380,39 @@ Singleton {
isNiri = true
isHyprland = false
isDwl = false
isSway = false
compositor = "niri"
console.info("CompositorService: Detected Niri with socket:", niriSocket)
NiriService.generateNiriBinds()
NiriService.generateNiriBlurrule()
} else {
isHyprland = false
isNiri = true
isDwl = false
compositor = "niri"
console.warn("CompositorService: Niri socket check failed, defaulting to Niri anyway")
}
}, 0)
return
}
if (swaySocket && swaySocket.length > 0) {
Proc.runCommand("swaySocketCheck", ["test", "-S", swaySocket], (output, exitCode) => {
if (exitCode === 0) {
isNiri = false
isHyprland = false
isDwl = false
isSway = true
compositor = "sway"
console.info("CompositorService: Detected Sway with socket:", swaySocket)
}
}, 0)
return
}
if (DMSService.dmsAvailable) {
Qt.callLater(checkForDwl)
} else {
if (DMSService.dmsAvailable) {
Qt.callLater(checkForDwl)
} else {
isHyprland = false
isNiri = false
isDwl = false
compositor = "unknown"
console.warn("CompositorService: No compositor detected")
}
isHyprland = false
isNiri = false
isDwl = false
isSway = false
compositor = "unknown"
console.warn("CompositorService: No compositor detected")
}
}
@@ -425,6 +439,7 @@ Singleton {
if (isNiri) return NiriService.powerOffMonitors()
if (isHyprland) return Hyprland.dispatch("dpms off")
if (isDwl) return _dwlPowerOffMonitors()
if (isSway) { try { I3.dispatch("output * dpms off") } catch(_){} return }
console.warn("CompositorService: Cannot power off monitors, unknown compositor")
}
@@ -432,6 +447,7 @@ Singleton {
if (isNiri) return NiriService.powerOnMonitors()
if (isHyprland) return Hyprland.dispatch("dpms on")
if (isDwl) return _dwlPowerOnMonitors()
if (isSway) { try { I3.dispatch("output * dpms on") } catch(_){} return }
console.warn("CompositorService: Cannot power on monitors, unknown compositor")
}

View File

@@ -6,6 +6,7 @@ import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Hyprland
import Quickshell.I3
import Quickshell.Wayland
import qs.Common
@@ -189,6 +190,11 @@ Singleton {
return
}
if (CompositorService.isSway) {
try { I3.dispatch("exit") } catch(_){}
return
}
Hyprland.dispatch("exit")
} else {
Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLogout])