aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/service.vala30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/service.vala b/src/service.vala
index e07e9fd..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,9 +225,26 @@ 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");
- unowned string desktop = Environment.get_variable ("XDG_CURRENT_DESKTOP");
string cmd;
if (Environment.get_variable ("MIR_SOCKET") != null)
@@ -239,16 +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
- {
cmd = "gnome-control-center sound";
- foreach (var name in desktop.split(":")) {
- if (name == "Unity" && Environment.find_program_in_path ("unity-control-center") != null) {
- cmd = "unity-control-center sound";
- break;
- }
- }
- }
try {
Process.spawn_command_line_async (cmd);