Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play login sound #1376

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions data/gala.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@
</key>
</schema>

<schema path="/org/pantheon/desktop/gala/sounds/" id="org.pantheon.desktop.gala.sounds">
<key type="b" name="play-login-sound">
<default>true</default>
<summary>Play login sound</summary>
<description>Whether a sound should be played on login.</description>
</key>
</schema>

<schema path="/org/pantheon/desktop/gala/mask-corners/" id="org.pantheon.desktop.gala.mask-corners">
<key type="b" name="enable">
<default>true</default>
Expand Down
47 changes: 47 additions & 0 deletions src/SessionStateManager.vala
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*/

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);
}
}
}
11 changes: 11 additions & 0 deletions src/WorkspaceManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace Gala {

public WindowManager wm { get; construct; }

private SessionStateManager session_state;

Gee.LinkedList<Workspace> workspaces_marked_removed;
int remove_freeze_count = 0;

Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gala_bin_sources = files(
'ScreenSaverManager.vala',
'ScreenshotManager.vala',
'SessionManager.vala',
'SessionStateManager.vala',
'ShadowEffect.vala',
'WindowListener.vala',
'WindowManager.vala',
Expand Down