diff options
Diffstat (limited to 'src/service.vala')
-rw-r--r-- | src/service.vala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/service.vala b/src/service.vala index 970867f..6835896 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); }); + if (GLib.Environment.get_user_name() != "lightdm") { + accounts_service = new AccountsServiceUser(); + } + this.sync_preferred_players (); this.settings.changed["interested-media-players"].connect ( () => { this.sync_preferred_players (); @@ -115,6 +119,7 @@ public class IndicatorSound.Service: Object { uint player_action_update_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(). @@ -316,12 +321,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; |