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 f021764..debf8bb 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 {
@@ -97,6 +98,14 @@ public class AccountsServiceUser : Object {
null,
new_proxy);
});
+
+ Bus.get_proxy.begin<GreeterBroadcast> (
+ BusType.SYSTEM,
+ "com.canonical.Unity.Greeter.Broadcast",
+ "/com/canonical/Unity/Greeter/Broadcast",
+ DBusProxyFlags.NONE,
+ null,
+ greeter_proxy_new);
}
~AccountsServiceUser () {
@@ -112,4 +121,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);
+ }
+ }
}