1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-07 22:18:30 -04:00

lock: set LockedHint when locking with loginctl lock integration

- was previously read-only
fixes #2732
This commit is contained in:
bbedward
2026-07-02 22:57:09 -04:00
parent 31efe9b385
commit 186621ab81
4 changed files with 42 additions and 0 deletions
+13
View File
@@ -46,6 +46,19 @@ func (m *Manager) Activate() error {
return nil return nil
} }
func (m *Manager) SetLockedHint(locked bool) error {
err := m.sessionObj.Call(dbusSessionInterface+".SetLockedHint", 0, locked).Err
if err != nil {
if refreshErr := m.refreshSessionBinding(); refreshErr == nil {
err = m.sessionObj.Call(dbusSessionInterface+".SetLockedHint", 0, locked).Err
}
if err != nil {
return fmt.Errorf("failed to set locked hint: %w", err)
}
}
return nil
}
func (m *Manager) SetIdleHint(idle bool) error { func (m *Manager) SetIdleHint(idle bool) error {
err := m.sessionObj.Call(dbusSessionInterface+".SetIdleHint", 0, idle).Err err := m.sessionObj.Call(dbusSessionInterface+".SetIdleHint", 0, idle).Err
if err != nil { if err != nil {
+16
View File
@@ -21,6 +21,8 @@ func HandleRequest(conn net.Conn, req models.Request, manager *Manager) {
handleActivate(conn, req, manager) handleActivate(conn, req, manager)
case "loginctl.setIdleHint": case "loginctl.setIdleHint":
handleSetIdleHint(conn, req, manager) handleSetIdleHint(conn, req, manager)
case "loginctl.setLockedHint":
handleSetLockedHint(conn, req, manager)
case "loginctl.setLockBeforeSuspend": case "loginctl.setLockBeforeSuspend":
handleSetLockBeforeSuspend(conn, req, manager) handleSetLockBeforeSuspend(conn, req, manager)
case "loginctl.setSleepInhibitorEnabled": case "loginctl.setSleepInhibitorEnabled":
@@ -78,6 +80,20 @@ func handleSetIdleHint(conn net.Conn, req models.Request, manager *Manager) {
models.Respond(conn, req.ID, models.SuccessResult{Success: true, Message: "idle hint set"}) models.Respond(conn, req.ID, models.SuccessResult{Success: true, Message: "idle hint set"})
} }
func handleSetLockedHint(conn net.Conn, req models.Request, manager *Manager) {
locked, err := params.Bool(req.Params, "locked")
if err != nil {
models.RespondError(conn, req.ID, err.Error())
return
}
if err := manager.SetLockedHint(locked); err != nil {
models.RespondError(conn, req.ID, err.Error())
return
}
models.Respond(conn, req.ID, models.SuccessResult{Success: true, Message: "locked hint set"})
}
func handleSetLockBeforeSuspend(conn net.Conn, req models.Request, manager *Manager) { func handleSetLockBeforeSuspend(conn net.Conn, req models.Request, manager *Manager) {
enabled, err := params.Bool(req.Params, "enabled") enabled, err := params.Bool(req.Params, "enabled")
if err != nil { if err != nil {
+7
View File
@@ -49,6 +49,12 @@ Scope {
lock(); lock();
} }
function notifyLockedHint(locked: bool) {
if (!SettingsData.loginctlLockIntegration || !DMSService.isConnected)
return;
DMSService.setLockedHint(locked, () => {});
}
function notifyLoginctl(lockAction: bool) { function notifyLoginctl(lockAction: bool) {
if (!SettingsData.loginctlLockIntegration || !DMSService.isConnected) if (!SettingsData.loginctlLockIntegration || !DMSService.isConnected)
return; return;
@@ -217,6 +223,7 @@ Scope {
target: sessionLock target: sessionLock
function onLockedChanged() { function onLockedChanged() {
notifyLockedHint(sessionLock.locked);
if (sessionLock.locked) { if (sessionLock.locked) {
pendingLock = false; pendingLock = false;
if (lockPowerOffArmed && SettingsData.lockScreenPowerOffMonitorsOnLock) { if (lockPowerOffArmed && SettingsData.lockScreenPowerOffMonitorsOnLock) {
+6
View File
@@ -620,6 +620,12 @@ Singleton {
sendRequest("loginctl.unlock", null, callback); sendRequest("loginctl.unlock", null, callback);
} }
function setLockedHint(locked, callback) {
sendRequest("loginctl.setLockedHint", {
"locked": locked
}, callback);
}
function bluetoothPair(devicePath, callback) { function bluetoothPair(devicePath, callback) {
sendRequest("bluetooth.pair", { sendRequest("bluetooth.pair", {
"device": devicePath "device": devicePath