aboutsummaryrefslogtreecommitdiff
path: root/src/service.vala
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@ubuntu.com>2016-04-06 19:05:09 +0000
committerCI Train Bot <ci-train-bot@canonical.com>2016-04-06 19:05:09 +0000
commitcc1942c03450ed4d273ea47a259ee73997655cd0 (patch)
tree3d67caa40dc14b3eba6b2511fb606b4a010f22e5 /src/service.vala
parentd030b55288d8d31c0d8a788422588c93157fdc55 (diff)
parent3d3a9b5b084ebecc06c2b67b220f0d2a8fecd839 (diff)
downloadayatana-indicator-sound-cc1942c03450ed4d273ea47a259ee73997655cd0.tar.gz
ayatana-indicator-sound-cc1942c03450ed4d273ea47a259ee73997655cd0.tar.bz2
ayatana-indicator-sound-cc1942c03450ed4d273ea47a259ee73997655cd0.zip
Support multiple desktop names in $XDG_CURRENT_DESKTOP. Fixes: #1502480
Approved by: Alkis Georgopoulos, Mystic-Mirage, Charles Kerr, Alberts Muktupāvels
Diffstat (limited to 'src/service.vala')
-rw-r--r--src/service.vala28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/service.vala b/src/service.vala
index 651ec73..33008a1 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -206,6 +206,7 @@ public class IndicatorSound.Service: Object {
private VolumeWarning _volume_warning;
private IndicatorSound.InfoNotification _info_notification = new IndicatorSound.InfoNotification();
private AccountsServiceAccess _accounts_service_access;
+ bool? is_unity = null;
const double volume_step_percentage = 0.06;
@@ -224,6 +225,24 @@ public class IndicatorSound.Service: Object {
}
}
+ private bool desktop_is_unity() {
+ if (is_unity != null) {
+ return is_unity;
+ }
+
+ is_unity = false;
+ unowned string desktop = Environment.get_variable ("XDG_CURRENT_DESKTOP");
+
+ foreach (var name in desktop.split(":")) {
+ if (name == "Unity") {
+ is_unity = true;
+ break;
+ }
+ }
+
+ return is_unity;
+ }
+
void activate_desktop_settings (SimpleAction action, Variant? param) {
unowned string env = Environment.get_variable ("DESKTOP_SESSION");
string cmd;
@@ -238,13 +257,10 @@ public class IndicatorSound.Service: Object {
cmd = "pavucontrol";
else if (env == "mate")
cmd = "mate-volume-control";
+ else if (desktop_is_unity() && Environment.find_program_in_path ("unity-control-center") != null)
+ cmd = "unity-control-center sound";
else
- {
- if (Environment.get_variable ("XDG_CURRENT_DESKTOP") == "Unity" && Environment.find_program_in_path ("unity-control-center") != null)
- cmd = "unity-control-center sound";
- else
- cmd = "gnome-control-center sound";
- }
+ cmd = "gnome-control-center sound";
try {
Process.spawn_command_line_async (cmd);