-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run our session manager as a separate process (#779)
- Loading branch information
Showing
10 changed files
with
137 additions
and
127 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,12 @@ | ||
/* -*- Mode:Vala; indent-tabs-mode:nil; tab-width:4 -*- | ||
* | ||
* Copyright (C) 2011 Canonical Ltd | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Authored by: Michael Terry <[email protected]> | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) | ||
*/ | ||
|
||
public class GreeterCompositor.SettingsDaemon : Object { | ||
private GreeterCompositor.GnomeSessionManager session_manager; | ||
private int n_names = 0; | ||
private SubprocessSupervisor[] supervisors = {}; | ||
|
||
public void start () { | ||
/* Pretend to be GNOME session */ | ||
session_manager = new GreeterCompositor.GnomeSessionManager (); | ||
n_names++; | ||
GLib.Bus.own_name (BusType.SESSION, "org.gnome.SessionManager", BusNameOwnerFlags.NONE, | ||
(c) => { | ||
try { | ||
c.register_object ("/org/gnome/SessionManager", session_manager); | ||
} catch (Error e) { | ||
warning ("Failed to register /org/gnome/SessionManager: %s", e.message); | ||
} | ||
}, | ||
() => { | ||
debug ("Acquired org.gnome.SessionManager"); | ||
start_settings_daemon (); | ||
}, | ||
() => debug ("Failed to acquire name org.gnome.SessionManager")); | ||
} | ||
|
||
private void start_settings_daemon () { | ||
n_names--; | ||
if (n_names != 0) { | ||
return; | ||
} | ||
|
||
debug ("All bus names acquired, starting gnome-settings-daemon"); | ||
|
||
string[] daemons = { | ||
"gsd-a11y-settings", | ||
"gsd-color", | ||
"gsd-media-keys", | ||
"gsd-sound", | ||
"gsd-power", | ||
"gsd-xsettings" | ||
}; | ||
|
||
foreach (var daemon in daemons) { | ||
try { | ||
supervisors += new GreeterCompositor.SubprocessSupervisor ({Constants.GSD_DIR + daemon}); | ||
} catch (GLib.Error e) { | ||
critical ("Could not start %s: %s", daemon, e.message); | ||
} | ||
} | ||
} | ||
} | ||
|
||
[DBus (name="org.gnome.SessionManager")] | ||
public class GreeterCompositor.GnomeSessionManager : GLib.Object { | ||
private Gee.ArrayList<GreeterCompositor.GnomeSessionManagerClient> clients; | ||
private Gee.ArrayList<unowned GreeterCompositor.GnomeSessionManagerClient> inhibitors; | ||
public class GreeterSessionManager.GnomeSessionManager : GLib.Object { | ||
private Gee.ArrayList<GnomeSessionManagerClient> clients; | ||
private Gee.ArrayList<unowned GnomeSessionManagerClient> inhibitors; | ||
|
||
public string session_name { owned get; set; default = "pantheon"; } | ||
public string renderer { owned get; set; default = ""; } | ||
|
@@ -86,8 +21,8 @@ public class GreeterCompositor.GnomeSessionManager : GLib.Object { | |
public signal void session_over (); | ||
|
||
construct { | ||
clients = new Gee.ArrayList<GreeterCompositor.GnomeSessionManagerClient> (); | ||
inhibitors = new Gee.ArrayList<unowned GreeterCompositor.GnomeSessionManagerClient> (); | ||
clients = new Gee.ArrayList<GnomeSessionManagerClient> (); | ||
inhibitors = new Gee.ArrayList<unowned GnomeSessionManagerClient> (); | ||
} | ||
|
||
public void setenv (string variable, string value) throws GLib.Error { | ||
|
@@ -188,7 +123,7 @@ public class GreeterCompositor.GnomeSessionManager : GLib.Object { | |
} | ||
|
||
[DBus (name = "org.gnome.SessionManager.Client")] | ||
public class GreeterCompositor.GnomeSessionManagerClient : GLib.Object { | ||
public class GreeterSessionManager.GnomeSessionManagerClient : GLib.Object { | ||
static uint32 serial_id = 0; | ||
|
||
private string app_id; | ||
|
@@ -203,7 +138,7 @@ public class GreeterCompositor.GnomeSessionManagerClient : GLib.Object { | |
|
||
try { | ||
var session_bus = GLib.Bus.get_sync (GLib.BusType.SESSION); | ||
session_bus.register_object<GreeterCompositor.GnomeSessionManagerClient> (object_path, this); | ||
session_bus.register_object<GnomeSessionManagerClient> (object_path, this); | ||
} catch (Error e) { | ||
critical (e.message); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* SPDX-FileCopyrightText: 2011 Canonical Ltd | ||
* 2025 elementary, Inc. (https://elementary.io) | ||
*/ | ||
|
||
public class GreeterSessionManager.SettingsDaemon : GLib.Object { | ||
private const string[] DAEMONS = { | ||
"gsd-a11y-settings", | ||
"gsd-color", | ||
"gsd-media-keys", | ||
"gsd-sound", | ||
"gsd-power", | ||
"gsd-xsettings" | ||
}; | ||
|
||
private SubprocessSupervisor[] supervisors = {}; | ||
|
||
construct { | ||
/* Pretend to be GNOME session */ | ||
GLib.Bus.own_name ( | ||
BusType.SESSION, "org.gnome.SessionManager", BusNameOwnerFlags.NONE, | ||
(connection) => { | ||
try { | ||
connection.register_object ("/org/gnome/SessionManager", new GnomeSessionManager ()); | ||
} catch (Error e) { | ||
critical ("Failed to register /org/gnome/SessionManager: %s", e.message); | ||
} | ||
}, | ||
() => { | ||
debug ("Acquired org.gnome.SessionManager"); | ||
start_settings_daemon (); | ||
}, | ||
() => { | ||
critical ("Lost org.gnome.SessionManager"); | ||
} | ||
); | ||
} | ||
|
||
private void start_settings_daemon () { | ||
debug ("All bus names acquired, starting gnome-settings-daemon"); | ||
|
||
foreach (unowned var daemon in DAEMONS) { | ||
try { | ||
supervisors += new SubprocessSupervisor ({ Constants.GSD_DIR + daemon }); | ||
} catch (Error e) { | ||
critical ("Could not start %s: %s", daemon, e.message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
* SPDX-FileCopyrightText: 2018, 2025 elementary, Inc. (https://elementary.io) | ||
* Authors: Corentin Noël <[email protected]> | ||
*/ | ||
|
||
public class GreeterSessionManager.SubprocessSupervisor : GLib.Object { | ||
public string[] exec { get; construct; } | ||
|
||
private GLib.Subprocess? subprocess = null; | ||
|
||
public SubprocessSupervisor (string[] exec) throws GLib.Error { | ||
Object (exec: exec); | ||
} | ||
|
||
construct { | ||
ensure_run.begin (); | ||
} | ||
|
||
~SubprocessSupervisor () { | ||
if (subprocess != null) { | ||
subprocess.force_exit (); | ||
} | ||
} | ||
|
||
private async void ensure_run () { | ||
try { | ||
subprocess = new GLib.Subprocess.newv (exec, GLib.SubprocessFlags.STDIN_INHERIT | GLib.SubprocessFlags.STDERR_MERGE); | ||
|
||
if (!yield subprocess.wait_check_async ()) { | ||
ensure_run.begin (); | ||
} | ||
} catch (Error e) { | ||
critical ("Couldn't create subprocess: %s", e.message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) | ||
*/ | ||
|
||
public class GreeterSessionManager.Application : GLib.Object { | ||
public static int main (string[] args) { | ||
new SettingsDaemon (); | ||
|
||
var loop = new GLib.MainLoop (GLib.MainContext.default (), true); | ||
loop.run (); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
gee_dep = dependency('gee-0.8') | ||
gio_dep = dependency('gio-2.0') | ||
glib_dep = dependency('glib-2.0') | ||
gobject_dep = dependency('gobject-2.0') | ||
|
||
install_path = join_paths(get_option('prefix'), get_option('sbindir')) | ||
|
||
files = files( | ||
'main.vala', | ||
'SessionManager.vala', | ||
'SettingsDaemon.vala', | ||
'SubprocessSupervisor.vala' | ||
) | ||
|
||
executable( | ||
meson.project_name()+'-session-manager', | ||
files, | ||
config_header, | ||
dependencies: [ gee_dep, gio_dep, glib_dep, gobject_dep ], | ||
install : true, | ||
install_dir: install_path | ||
) |