aboutsummaryrefslogtreecommitdiff
path: root/src/accounts-service-user.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/accounts-service-user.vala')
-rw-r--r--src/accounts-service-user.vala42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala
index c29842a..4dd7e6f 100644
--- a/src/accounts-service-user.vala
+++ b/src/accounts-service-user.vala
@@ -23,6 +23,7 @@ public class AccountsServiceUser : Object {
AccountsServiceSoundSettings? proxy = null;
uint timer = 0;
MediaPlayer? _player = null;
+ GreeterBroadcast? greeter = null;
public MediaPlayer? player {
set {
@@ -95,6 +96,14 @@ public class AccountsServiceUser : Object {
user = accounts_manager.get_user(GLib.Environment.get_user_name());
user.notify["is-loaded"].connect(() => user_loaded_changed());
user_loaded_changed();
+
+ Bus.get_proxy.begin<GreeterBroadcast> (
+ BusType.SYSTEM,
+ "com.canonical.Unity.Greeter.Broadcast",
+ "/com/canonical/Unity/Greeter/Broadcast",
+ DBusProxyFlags.NONE,
+ null,
+ greeter_proxy_new);
}
void user_loaded_changed () {
@@ -132,4 +141,37 @@ public class AccountsServiceUser : Object {
warning("Unable to get proxy to user sound settings: %s", e.message);
}
}
+
+ void greeter_proxy_new (GLib.Object? obj, AsyncResult res) {
+ try {
+ this.greeter = Bus.get_proxy.end (res);
+
+ this.greeter.SoundPlayPause.connect((username) => {
+ if (username != GLib.Environment.get_user_name())
+ return;
+ if (this._player == null)
+ return;
+ this._player.play_pause();
+ });
+
+ this.greeter.SoundNext.connect((username) => {
+ if (username != GLib.Environment.get_user_name())
+ return;
+ if (this._player == null)
+ return;
+ this._player.next();
+ });
+
+ this.greeter.SoundPrev.connect((username) => {
+ if (username != GLib.Environment.get_user_name())
+ return;
+ if (this._player == null)
+ return;
+ this._player.previous();
+ });
+ } catch (Error e) {
+ this.greeter = null;
+ warning("Unable to get greeter proxy: %s", e.message);
+ }
+ }
}