aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/service.vala b/src/service.vala
index d4a5bc6..d94aa18 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -46,6 +46,10 @@ public class IndicatorSound.Service: Object {
this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);
});
+ /* Setup handling for the greeter-export setting */
+ this.settings.changed["greeter-export"].connect( () => this.build_accountsservice() );
+ build_accountsservice();
+
this.sync_preferred_players ();
this.settings.changed["interested-media-players"].connect ( () => {
this.sync_preferred_players ();
@@ -62,6 +66,22 @@ public class IndicatorSound.Service: Object {
sharedsettings.bind ("allow-amplified-volume", this, "allow-amplified-volume", SettingsBindFlags.GET);
}
+ void build_accountsservice () {
+ this.accounts_service = null;
+
+ /* If we're not exporting, don't build anything */
+ if (!this.settings.get_boolean("greeter-export")) {
+ return;
+ }
+
+ /* If we're on the greeter, don't export */
+ if (GLib.Environment.get_user_name() == "lightdm") {
+ return;
+ }
+
+ this.accounts_service = new AccountsServiceUser();
+ }
+
public int run () {
if (this.loop != null) {
warning ("service is already running");
@@ -117,6 +137,7 @@ public class IndicatorSound.Service: Object {
uint sound_was_blocked_timeout_id;
Notify.Notification notification;
bool syncing_preferred_players = false;
+ AccountsServiceUser? accounts_service = null;
/* Maximum volume as a scaling factor between the volume action's state and the value in
* this.volume_control. See create_volume_action().
@@ -343,12 +364,24 @@ public class IndicatorSound.Service: Object {
}
bool update_player_actions () {
+ bool clear_accounts_player = true;
+
foreach (var player in this.players) {
SimpleAction? action = this.actions.lookup_action (player.id) as SimpleAction;
if (action != null) {
action.set_state (this.action_state_for_player (player));
action.set_enabled (player.can_raise);
}
+
+ /* If we're playing then put that data in accounts service */
+ if (player.is_running && accounts_service != null) {
+ accounts_service.player = player;
+ clear_accounts_player = false;
+ }
+ }
+
+ if (clear_accounts_player && accounts_service != null) {
+ accounts_service.player = null;
}
this.player_action_update_id = 0;