diff --git a/data/gala.gschema.xml b/data/gala.gschema.xml index 95ff0386e..d98af43b0 100644 --- a/data/gala.gschema.xml +++ b/data/gala.gschema.xml @@ -324,6 +324,14 @@ + + + true + Play login sound + Whether a sound should be played on login. + + + true diff --git a/src/SessionStateManager.vala b/src/SessionStateManager.vala new file mode 100644 index 000000000..d50666a4a --- /dev/null +++ b/src/SessionStateManager.vala @@ -0,0 +1,47 @@ +/* + * Copyright 2022 elementary, Inc. (https://elementary.io) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * 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, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authored by: Marius Meisenzahl + */ + +public class Gala.SessionStateManager : Object { + [DBus (name = "org.gnome.SessionManager")] + private interface SessionManagerInterface : Object { + public abstract signal void session_running (); + } + + private SessionManagerInterface session_manager; + + public signal void session_running (); + + async construct { + init.begin (); + } + + private async void init () { + try { + session_manager = yield Bus.get_proxy (BusType.SESSION, "org.gnome.SessionManager", "/org/gnome/SessionManager"); + + session_manager.session_running.connect (() => { + session_running (); + }); + } catch (Error e) { + warning ("Could not connect to system bus: %s", e.message); + } + } +} diff --git a/src/WorkspaceManager.vala b/src/WorkspaceManager.vala index 6455e442f..29481e75d 100644 --- a/src/WorkspaceManager.vala +++ b/src/WorkspaceManager.vala @@ -31,6 +31,8 @@ namespace Gala { public WindowManager wm { get; construct; } + private SessionStateManager session_state; + Gee.LinkedList workspaces_marked_removed; int remove_freeze_count = 0; @@ -46,6 +48,15 @@ namespace Gala { // There are some empty workspace at startup cleanup (); + session_state = new SessionStateManager (); + session_state.session_running.connect (() => { + var sounds_settings = new GLib.Settings ("org.pantheon.desktop.gala.sounds"); + if (sounds_settings.get_boolean ("play-login-sound")) { + unowned Meta.SoundPlayer sound_player = display.get_sound_player (); + sound_player.play_from_theme ("login", "", null); + } + }); + if (Prefs.get_dynamic_workspaces ()) manager.override_workspace_layout (DisplayCorner.TOPLEFT, false, 1, -1); diff --git a/src/meson.build b/src/meson.build index d475729a7..d7e72d0f4 100644 --- a/src/meson.build +++ b/src/meson.build @@ -13,6 +13,7 @@ gala_bin_sources = files( 'ScreenSaverManager.vala', 'ScreenshotManager.vala', 'SessionManager.vala', + 'SessionStateManager.vala', 'ShadowEffect.vala', 'WindowListener.vala', 'WindowManager.vala',