mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-30 00:12:50 -05:00
Portal/Loginctl fallbacks for DMS_SOCKET unavail
This commit is contained in:
@@ -13,7 +13,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (SessionService.loginctlAvailable) {
|
if (SessionService.loginctlAvailable || SessionService.sessionPath) {
|
||||||
if (SessionService.locked || SessionService.lockedHint) {
|
if (SessionService.locked || SessionService.lockedHint) {
|
||||||
console.log("Lock: Session locked on startup")
|
console.log("Lock: Session locked on startup")
|
||||||
loader.activeAsync = true
|
loader.activeAsync = true
|
||||||
|
|||||||
@@ -21,22 +21,24 @@ Singleton {
|
|||||||
function init() {}
|
function init() {}
|
||||||
|
|
||||||
function getSystemProfileImage() {
|
function getSystemProfileImage() {
|
||||||
if (!freedeskAvailable || !dmsService || !dmsService.service) return
|
if (freedeskAvailable && dmsService && dmsService.service) {
|
||||||
|
const username = Quickshell.env("USER")
|
||||||
|
if (!username) return
|
||||||
|
|
||||||
const username = Quickshell.env("USER")
|
dmsService.service.sendRequest("freedesktop.accounts.getUserIconFile", { username: username }, response => {
|
||||||
if (!username) return
|
if (response.result && response.result.success) {
|
||||||
|
const iconFile = response.result.value || ""
|
||||||
dmsService.service.sendRequest("freedesktop.accounts.getUserIconFile", { username: username }, response => {
|
if (iconFile && iconFile !== "" && iconFile !== "/var/lib/AccountsService/icons/") {
|
||||||
if (response.result && response.result.success) {
|
systemProfileImage = iconFile
|
||||||
const iconFile = response.result.value || ""
|
if (!profileImage || profileImage === "") {
|
||||||
if (iconFile && iconFile !== "" && iconFile !== "/var/lib/AccountsService/icons/") {
|
profileImage = iconFile
|
||||||
systemProfileImage = iconFile
|
}
|
||||||
if (!profileImage || profileImage === "") {
|
|
||||||
profileImage = iconFile
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
} else {
|
||||||
|
systemProfileCheckProcess.running = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserProfileImage(username) {
|
function getUserProfileImage(username) {
|
||||||
@@ -48,20 +50,27 @@ Singleton {
|
|||||||
profileImage = ""
|
profileImage = ""
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!freedeskAvailable || !dmsService || !dmsService.service) return
|
|
||||||
|
|
||||||
dmsService.service.sendRequest("freedesktop.accounts.getUserIconFile", { username: username }, response => {
|
if (freedeskAvailable && dmsService && dmsService.service) {
|
||||||
if (response.result && response.result.success) {
|
dmsService.service.sendRequest("freedesktop.accounts.getUserIconFile", { username: username }, response => {
|
||||||
const icon = response.result.value || ""
|
if (response.result && response.result.success) {
|
||||||
if (icon && icon !== "" && icon !== "/var/lib/AccountsService/icons/") {
|
const icon = response.result.value || ""
|
||||||
profileImage = icon
|
if (icon && icon !== "" && icon !== "/var/lib/AccountsService/icons/") {
|
||||||
|
profileImage = icon
|
||||||
|
} else {
|
||||||
|
profileImage = ""
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
profileImage = ""
|
profileImage = ""
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
profileImage = ""
|
} else {
|
||||||
}
|
userProfileCheckProcess.command = [
|
||||||
})
|
"bash", "-c",
|
||||||
|
`uid=$(id -u ${username} 2>/dev/null) && [ -n "$uid" ] && dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User$uid org.freedesktop.DBus.Properties.Get string:org.freedesktop.Accounts.User string:IconFile 2>/dev/null | grep -oP 'string "\\K[^"]+' || echo ""`
|
||||||
|
]
|
||||||
|
userProfileCheckProcess.running = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setProfileImage(imagePath) {
|
function setProfileImage(imagePath) {
|
||||||
@@ -76,23 +85,25 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSystemColorScheme() {
|
function getSystemColorScheme() {
|
||||||
if (!freedeskAvailable || !dmsService || !dmsService.service) return
|
if (freedeskAvailable && dmsService && dmsService.service) {
|
||||||
|
dmsService.service.sendRequest("freedesktop.settings.getColorScheme", null, response => {
|
||||||
|
if (response.result) {
|
||||||
|
systemColorScheme = response.result.value || 0
|
||||||
|
|
||||||
dmsService.service.sendRequest("freedesktop.settings.getColorScheme", null, response => {
|
if (typeof Theme !== "undefined") {
|
||||||
if (response.result) {
|
const shouldBeLightMode = (systemColorScheme === 2)
|
||||||
systemColorScheme = response.result.value || 0
|
if (Theme.isLightMode !== shouldBeLightMode) {
|
||||||
|
Theme.isLightMode = shouldBeLightMode
|
||||||
if (typeof Theme !== "undefined") {
|
if (typeof SessionData !== "undefined") {
|
||||||
const shouldBeLightMode = (systemColorScheme === 2)
|
SessionData.setLightMode(shouldBeLightMode)
|
||||||
if (Theme.isLightMode !== shouldBeLightMode) {
|
}
|
||||||
Theme.isLightMode = shouldBeLightMode
|
|
||||||
if (typeof SessionData !== "undefined") {
|
|
||||||
SessionData.setLightMode(shouldBeLightMode)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
} else {
|
||||||
|
systemColorSchemeCheckProcess.running = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLightMode(isLightMode) {
|
function setLightMode(isLightMode) {
|
||||||
@@ -121,19 +132,39 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setSystemProfileImage(imagePath) {
|
function setSystemProfileImage(imagePath) {
|
||||||
if (!accountsServiceAvailable || !freedeskAvailable || !dmsService || !dmsService.service) return
|
if (!accountsServiceAvailable) return
|
||||||
|
|
||||||
dmsService.service.sendRequest("freedesktop.accounts.setIconFile", { path: imagePath || "" }, response => {
|
if (freedeskAvailable && dmsService && dmsService.service) {
|
||||||
if (response.error) {
|
dmsService.service.sendRequest("freedesktop.accounts.setIconFile", { path: imagePath || "" }, response => {
|
||||||
console.warn("PortalService: Failed to set icon file:", response.error)
|
if (response.error) {
|
||||||
} else {
|
console.warn("PortalService: Failed to set icon file:", response.error)
|
||||||
Qt.callLater(() => getSystemProfileImage())
|
} else {
|
||||||
}
|
Qt.callLater(() => getSystemProfileImage())
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const path = imagePath || ""
|
||||||
|
systemProfileSetProcess.command = ["bash", "-c", `dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.Accounts.User.SetIconFile string:'${path}'`]
|
||||||
|
systemProfileSetProcess.running = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
Qt.callLater(initializeDMSConnection)
|
Qt.callLater(initializeDMSConnection)
|
||||||
|
fallbackCheckTimer.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: fallbackCheckTimer
|
||||||
|
interval: 1000
|
||||||
|
running: false
|
||||||
|
onTriggered: {
|
||||||
|
if (!freedeskAvailable) {
|
||||||
|
console.log("PortalService: DMS not available, using fallback methods")
|
||||||
|
checkAccountsServiceFallback()
|
||||||
|
checkSettingsPortalFallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeDMSConnection() {
|
function initializeDMSConnection() {
|
||||||
@@ -201,7 +232,14 @@ Singleton {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// For greeter use alternate method to get user profile image - since we dont run with dms
|
function checkAccountsServiceFallback() {
|
||||||
|
accountsServiceCheckProcess.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkSettingsPortalFallback() {
|
||||||
|
settingsPortalCheckProcess.running = true
|
||||||
|
}
|
||||||
|
|
||||||
function getGreeterUserProfileImage(username) {
|
function getGreeterUserProfileImage(username) {
|
||||||
if (!username) {
|
if (!username) {
|
||||||
profileImage = ""
|
profileImage = ""
|
||||||
@@ -214,6 +252,54 @@ Singleton {
|
|||||||
userProfileCheckProcess.running = true
|
userProfileCheckProcess.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: accountsServiceCheckProcess
|
||||||
|
command: ["bash", "-c", "dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts org.freedesktop.Accounts.FindUserByName string:\"$USER\""]
|
||||||
|
running: false
|
||||||
|
|
||||||
|
onExited: exitCode => {
|
||||||
|
accountsServiceAvailable = (exitCode === 0)
|
||||||
|
if (accountsServiceAvailable) {
|
||||||
|
getSystemProfileImage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: systemProfileCheckProcess
|
||||||
|
command: ["bash", "-c", "dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User$(id -u) org.freedesktop.DBus.Properties.Get string:org.freedesktop.Accounts.User string:IconFile"]
|
||||||
|
running: false
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
const match = text.match(/string\s+"([^"]+)"/)
|
||||||
|
if (match && match[1] && match[1] !== "" && match[1] !== "/var/lib/AccountsService/icons/") {
|
||||||
|
systemProfileImage = match[1]
|
||||||
|
if (!profileImage || profileImage === "") {
|
||||||
|
profileImage = systemProfileImage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: exitCode => {
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
systemProfileImage = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: systemProfileSetProcess
|
||||||
|
running: false
|
||||||
|
|
||||||
|
onExited: exitCode => {
|
||||||
|
if (exitCode === 0) {
|
||||||
|
getSystemProfileImage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: userProfileCheckProcess
|
id: userProfileCheckProcess
|
||||||
command: []
|
command: []
|
||||||
@@ -237,6 +323,50 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: settingsPortalCheckProcess
|
||||||
|
command: ["gdbus", "call", "--session", "--dest", "org.freedesktop.portal.Desktop", "--object-path", "/org/freedesktop/portal/desktop", "--method", "org.freedesktop.portal.Settings.ReadOne", "org.freedesktop.appearance", "color-scheme"]
|
||||||
|
running: false
|
||||||
|
|
||||||
|
onExited: exitCode => {
|
||||||
|
settingsPortalAvailable = (exitCode === 0)
|
||||||
|
if (settingsPortalAvailable) {
|
||||||
|
getSystemColorScheme()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: systemColorSchemeCheckProcess
|
||||||
|
command: ["gdbus", "call", "--session", "--dest", "org.freedesktop.portal.Desktop", "--object-path", "/org/freedesktop/portal/desktop", "--method", "org.freedesktop.portal.Settings.ReadOne", "org.freedesktop.appearance", "color-scheme"]
|
||||||
|
running: false
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
const match = text.match(/uint32 (\d+)/)
|
||||||
|
if (match && match[1]) {
|
||||||
|
systemColorScheme = parseInt(match[1])
|
||||||
|
|
||||||
|
if (typeof Theme !== "undefined") {
|
||||||
|
const shouldBeLightMode = (systemColorScheme === 2)
|
||||||
|
if (Theme.isLightMode !== shouldBeLightMode) {
|
||||||
|
Theme.isLightMode = shouldBeLightMode
|
||||||
|
if (typeof SessionData !== "undefined") {
|
||||||
|
SessionData.setLightMode(shouldBeLightMode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: exitCode => {
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
systemColorScheme = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "profile"
|
target: "profile"
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,19 @@ Singleton {
|
|||||||
detectPrimeRunProcess.running = true
|
detectPrimeRunProcess.running = true
|
||||||
console.log("SessionService: Native inhibitor available:", nativeInhibitorAvailable)
|
console.log("SessionService: Native inhibitor available:", nativeInhibitorAvailable)
|
||||||
Qt.callLater(initializeDMSConnection)
|
Qt.callLater(initializeDMSConnection)
|
||||||
|
fallbackCheckTimer.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: fallbackCheckTimer
|
||||||
|
interval: 1000
|
||||||
|
running: false
|
||||||
|
onTriggered: {
|
||||||
|
if (!loginctlAvailable) {
|
||||||
|
console.log("SessionService: DMS not available, using fallback methods")
|
||||||
|
initFallbackLoginctl()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,13 +423,100 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lockSession() {
|
function lockSession() {
|
||||||
if (!loginctlAvailable || !dmsService || !dmsService.service) return
|
if (loginctlAvailable && dmsService && dmsService.service) {
|
||||||
|
dmsService.service.sendRequest("loginctl.lock", null, response => {
|
||||||
|
if (response.error) {
|
||||||
|
console.warn("SessionService: Failed to lock session:", response.error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
lockSessionFallback.running = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dmsService.service.sendRequest("loginctl.lock", null, response => {
|
function initFallbackLoginctl() {
|
||||||
if (response.error) {
|
getSessionPathFallback.running = true
|
||||||
console.warn("SessionService: Failed to lock session:", response.error)
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: getSessionPathFallback
|
||||||
|
command: ["gdbus", "call", "--system", "--dest", "org.freedesktop.login1", "--object-path", "/org/freedesktop/login1", "--method", "org.freedesktop.login1.Manager.GetSession", Quickshell.env("XDG_SESSION_ID") || "self"]
|
||||||
|
running: false
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
const match = text.match(/objectpath '([^']+)'/)
|
||||||
|
if (match) {
|
||||||
|
sessionPath = match[1]
|
||||||
|
console.log("SessionService: Found session path (fallback):", sessionPath)
|
||||||
|
checkCurrentLockStateFallback.running = true
|
||||||
|
lockStateMonitorFallback.running = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: checkCurrentLockStateFallback
|
||||||
|
command: sessionPath ? ["gdbus", "call", "--system", "--dest", "org.freedesktop.login1", "--object-path", sessionPath, "--method", "org.freedesktop.DBus.Properties.Get", "org.freedesktop.login1.Session", "LockedHint"] : []
|
||||||
|
running: false
|
||||||
|
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
if (text.includes("true")) {
|
||||||
|
locked = true
|
||||||
|
lockedHint = true
|
||||||
|
sessionLocked()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: lockStateMonitorFallback
|
||||||
|
command: sessionPath ? ["gdbus", "monitor", "--system", "--dest", "org.freedesktop.login1"] : []
|
||||||
|
running: false
|
||||||
|
|
||||||
|
stdout: SplitParser {
|
||||||
|
splitMarker: "\n"
|
||||||
|
onRead: line => {
|
||||||
|
if (sessionPath && line.includes(sessionPath)) {
|
||||||
|
if (line.includes("org.freedesktop.login1.Session.Lock")) {
|
||||||
|
locked = true
|
||||||
|
lockedHint = true
|
||||||
|
sessionLocked()
|
||||||
|
} else if (line.includes("org.freedesktop.login1.Session.Unlock")) {
|
||||||
|
locked = false
|
||||||
|
lockedHint = false
|
||||||
|
sessionUnlocked()
|
||||||
|
} else if (line.includes("LockedHint") && line.includes("true")) {
|
||||||
|
locked = true
|
||||||
|
lockedHint = true
|
||||||
|
loginctlStateChanged()
|
||||||
|
} else if (line.includes("LockedHint") && line.includes("false")) {
|
||||||
|
locked = false
|
||||||
|
lockedHint = false
|
||||||
|
loginctlStateChanged()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (line.includes("PrepareForSleep") && line.includes("true") && SessionData.lockBeforeSuspend) {
|
||||||
|
preparingForSleep = true
|
||||||
|
prepareForSleep()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onExited: exitCode => {
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
console.warn("SessionService: gdbus monitor fallback failed, exit code:", exitCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: lockSessionFallback
|
||||||
|
command: ["loginctl", "lock-session"]
|
||||||
|
running: false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user