loginManager: Get user proxy for UID
Using the user object at `/org/freedesktop/login1/User/self` is convenient, but has the caveat that login1 does not emit the `PropertiesChanged` signal for the object. That is indeed logical, as for signal emissions there is no sender that can be used to resolve `self`. The new TimeLimitsManager depends on change notifications for user properties, so stop using the `self` shorthand and instead create the User proxy for the user's UID. Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8185 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3636>
This commit is contained in:
parent
a719b7039e
commit
5115236703
@ -17,6 +17,10 @@
|
||||
<arg type="s" direction="in"/>
|
||||
<arg type="o" direction="out"/>
|
||||
</method>
|
||||
<method name="GetUser">
|
||||
<arg type="u" direction="in"/>
|
||||
<arg type="o" direction="out"/>
|
||||
</method>
|
||||
<method name="ListSessions">
|
||||
<arg name="sessions" type="a(susso)" direction="out"/>
|
||||
</method>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import GLib from 'gi://GLib';
|
||||
import Gio from 'gi://Gio';
|
||||
import GioUnix from 'gi://GioUnix';
|
||||
import Shell from 'gi://Shell';
|
||||
import * as Signals from './signals.js';
|
||||
|
||||
import {loadInterfaceXML} from './fileUtils.js';
|
||||
@ -95,17 +96,26 @@ class LoginManagerSystemd extends Signals.EventEmitter {
|
||||
this._proxy = new SystemdLoginManager(Gio.DBus.system,
|
||||
'org.freedesktop.login1',
|
||||
'/org/freedesktop/login1');
|
||||
this._userProxy = new SystemdLoginUser(Gio.DBus.system,
|
||||
'org.freedesktop.login1',
|
||||
'/org/freedesktop/login1/user/self');
|
||||
this._proxy.connectSignal('PrepareForSleep',
|
||||
this._prepareForSleep.bind(this));
|
||||
this._proxy.connectSignal('SessionRemoved',
|
||||
this._sessionRemoved.bind(this));
|
||||
}
|
||||
|
||||
getCurrentUserProxy() {
|
||||
async getCurrentUserProxy() {
|
||||
if (this._userProxy)
|
||||
return this._userProxy;
|
||||
|
||||
const uid = Shell.util_get_uid();
|
||||
try {
|
||||
const [objectPath] = await this._proxy.GetUserAsync(uid);
|
||||
this._userProxy = await SystemdLoginUser.newAsync(
|
||||
Gio.DBus.system, 'org.freedesktop.login1', objectPath);
|
||||
return this._userProxy;
|
||||
} catch (error) {
|
||||
logError(error, `Could not get a proxy for user ${uid}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async getCurrentSessionProxy() {
|
||||
@ -115,14 +125,15 @@ class LoginManagerSystemd extends Signals.EventEmitter {
|
||||
let sessionId = GLib.getenv('XDG_SESSION_ID');
|
||||
if (!sessionId) {
|
||||
log('Unset XDG_SESSION_ID, getCurrentSessionProxy() called outside a user session. Asking logind directly.');
|
||||
let [session, objectPath] = this._userProxy.Display;
|
||||
const userProxy = await this.getCurrentUserProxy();
|
||||
let [session, objectPath] = userProxy.Display;
|
||||
if (session) {
|
||||
log(`Will monitor session ${session}`);
|
||||
sessionId = session;
|
||||
} else {
|
||||
log('Failed to find "Display" session; are we the greeter?');
|
||||
|
||||
for ([session, objectPath] of this._userProxy.Sessions) {
|
||||
for ([session, objectPath] of userProxy.Sessions) {
|
||||
let sessionProxy = new SystemdLoginSession(Gio.DBus.system,
|
||||
'org.freedesktop.login1',
|
||||
objectPath);
|
||||
|
Loading…
x
Reference in New Issue
Block a user