1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-10 07:25:37 -05:00

Support prime-run

This commit is contained in:
bbedward
2025-10-06 20:50:36 -04:00
parent d9d83e5767
commit 4c3b7ca60f
4 changed files with 187 additions and 5 deletions

View File

@@ -270,5 +270,68 @@ Popup {
} }
} }
} }
Rectangle {
visible: SessionService.hasPrimeRun
width: parent.width - Theme.spacingS * 2
height: 5
anchors.horizontalCenter: parent.horizontalCenter
color: "transparent"
Rectangle {
anchors.centerIn: parent
width: parent.width
height: 1
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
}
}
Rectangle {
visible: SessionService.hasPrimeRun
width: parent.width
height: 32
radius: Theme.cornerRadius
color: primeRunMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
Row {
anchors.left: parent.left
anchors.leftMargin: Theme.spacingS
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingS
DankIcon {
name: "memory"
size: Theme.iconSize - 2
color: Theme.surfaceText
opacity: 0.7
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: qsTr("Launch on dGPU")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
font.weight: Font.Normal
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
id: primeRunMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: () => {
if (contextMenu.currentApp && contextMenu.currentApp.desktopEntry) {
SessionService.launchDesktopEntry(contextMenu.currentApp.desktopEntry, true)
if (appLauncher) {
appLauncher.appLaunched(contextMenu.currentApp)
}
}
contextMenu.hide()
}
}
}
} }
} }

View File

@@ -913,6 +913,67 @@ DankPopout {
} }
} }
} }
Rectangle {
visible: SessionService.hasPrimeRun
width: parent.width - Theme.spacingS * 2
height: 5
anchors.horizontalCenter: parent.horizontalCenter
color: "transparent"
Rectangle {
anchors.centerIn: parent
width: parent.width
height: 1
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
}
}
Rectangle {
visible: SessionService.hasPrimeRun
width: parent.width
height: 32
radius: Theme.cornerRadius
color: primeRunMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
Row {
anchors.left: parent.left
anchors.leftMargin: Theme.spacingS
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingS
DankIcon {
name: "memory"
size: Theme.iconSize - 2
color: Theme.surfaceText
opacity: 0.7
anchors.verticalCenter: parent.verticalCenter
}
StyledText {
text: qsTr("Launch on dGPU")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
font.weight: Font.Normal
anchors.verticalCenter: parent.verticalCenter
}
}
MouseArea {
id: primeRunMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
if (contextMenu.currentApp && contextMenu.currentApp.desktopEntry) {
SessionService.launchDesktopEntry(contextMenu.currentApp.desktopEntry, true)
appLauncher.appLaunched(contextMenu.currentApp)
}
contextMenu.hide()
}
}
}
} }
} }

View File

@@ -404,7 +404,49 @@ PanelWindow {
} }
Rectangle { Rectangle {
visible: root.appData && root.appData.type === "window" visible: (root.appData && root.appData.type === "window") || (root.desktopEntry && SessionService.hasPrimeRun)
width: parent.width
height: 1
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
}
Rectangle {
visible: root.desktopEntry && SessionService.hasPrimeRun
width: parent.width
height: 28
radius: Theme.cornerRadius
color: primeRunArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent"
StyledText {
anchors.left: parent.left
anchors.leftMargin: Theme.spacingS
anchors.right: parent.right
anchors.rightMargin: Theme.spacingS
anchors.verticalCenter: parent.verticalCenter
text: qsTr("Launch on dGPU")
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
font.weight: Font.Normal
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
MouseArea {
id: primeRunArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
if (root.desktopEntry) {
SessionService.launchDesktopEntry(root.desktopEntry, true)
}
root.close()
}
}
}
Rectangle {
visible: root.appData && (root.appData.type === "window" || (root.appData.type === "grouped" && root.appData.windowCount > 0))
width: parent.width width: parent.width
height: 1 height: 1
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
@@ -444,7 +486,6 @@ PanelWindow {
onClicked: { onClicked: {
const sortedToplevels = CompositorService.sortedToplevels const sortedToplevels = CompositorService.sortedToplevels
if (root.appData && root.appData.type === "window") { if (root.appData && root.appData.type === "window") {
// Find and close the specific window
for (var i = 0; i < sortedToplevels.length; i++) { for (var i = 0; i < sortedToplevels.length; i++) {
const toplevel = sortedToplevels[i] const toplevel = sortedToplevels[i]
const checkId = toplevel.title + "|" + (toplevel.appId || "") + "|" + i const checkId = toplevel.title + "|" + (toplevel.appId || "") + "|" + i
@@ -454,7 +495,6 @@ PanelWindow {
} }
} }
} else if (root.appData && root.appData.type === "grouped") { } else if (root.appData && root.appData.type === "grouped") {
// Close all windows for this app
const allToplevels = ToplevelManager.toplevels.values const allToplevels = ToplevelManager.toplevels.values
for (let i = 0; i < allToplevels.length; i++) { for (let i = 0; i < allToplevels.length; i++) {
const toplevel = allToplevels[i] const toplevel = allToplevels[i]

View File

@@ -18,6 +18,7 @@ Singleton {
property bool inhibitorAvailable: true property bool inhibitorAvailable: true
property bool idleInhibited: false property bool idleInhibited: false
property string inhibitReason: "Keep system awake" property string inhibitReason: "Keep system awake"
property bool hasPrimeRun: false
readonly property bool nativeInhibitorAvailable: { readonly property bool nativeInhibitorAvailable: {
try { try {
@@ -30,6 +31,7 @@ Singleton {
Component.onCompleted: { Component.onCompleted: {
detectElogindProcess.running = true detectElogindProcess.running = true
detectHibernateProcess.running = true detectHibernateProcess.running = true
detectPrimeRunProcess.running = true
console.log("SessionService: Native inhibitor available:", nativeInhibitorAvailable) console.log("SessionService: Native inhibitor available:", nativeInhibitorAvailable)
} }
@@ -65,6 +67,16 @@ Singleton {
} }
} }
Process {
id: detectPrimeRunProcess
running: false
command: ["which", "prime-run"]
onExited: function (exitCode) {
hasPrimeRun = (exitCode === 0)
}
}
Process { Process {
id: uwsmLogout id: uwsmLogout
command: ["uwsm", "stop"] command: ["uwsm", "stop"]
@@ -88,8 +100,11 @@ Singleton {
} }
// * Apps // * Apps
function launchDesktopEntry(desktopEntry) { function launchDesktopEntry(desktopEntry, usePrimeRun) {
let cmd = desktopEntry.command let cmd = desktopEntry.command
if (usePrimeRun && hasPrimeRun) {
cmd = ["prime-run"].concat(cmd)
}
if (SessionData.launchPrefix && SessionData.launchPrefix.length > 0) { if (SessionData.launchPrefix && SessionData.launchPrefix.length > 0) {
const launchPrefix = SessionData.launchPrefix.trim().split(" ") const launchPrefix = SessionData.launchPrefix.trim().split(" ")
cmd = launchPrefix.concat(cmd) cmd = launchPrefix.concat(cmd)
@@ -101,8 +116,11 @@ Singleton {
}); });
} }
function launchDesktopAction(desktopEntry, action) { function launchDesktopAction(desktopEntry, action, usePrimeRun) {
let cmd = action.command let cmd = action.command
if (usePrimeRun && hasPrimeRun) {
cmd = ["prime-run"].concat(cmd)
}
if (SessionData.launchPrefix && SessionData.launchPrefix.length > 0) { if (SessionData.launchPrefix && SessionData.launchPrefix.length > 0) {
const launchPrefix = SessionData.launchPrefix.trim().split(" ") const launchPrefix = SessionData.launchPrefix.trim().split(" ")
cmd = launchPrefix.concat(cmd) cmd = launchPrefix.concat(cmd)