diff options
author | Robert Tari <robert@tari.in> | 2021-03-12 11:33:36 +0100 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2021-08-04 23:36:24 +0200 |
commit | 45bde614f382f0e0fc8777cd95b94e7e77b5fba0 (patch) | |
tree | e6446b1f447c213cd6d63299c0e15acb14dd7c62 /src/service.vala | |
parent | 67ea994225d646eddad7e7c063e9fdba421e305a (diff) | |
download | ayatana-indicator-sound-45bde614f382f0e0fc8777cd95b94e7e77b5fba0.tar.gz ayatana-indicator-sound-45bde614f382f0e0fc8777cd95b94e7e77b5fba0.tar.bz2 ayatana-indicator-sound-45bde614f382f0e0fc8777cd95b94e7e77b5fba0.zip |
src/service.vala: Display a zenity warning if the audio settings application is not found
fixes #12
Diffstat (limited to 'src/service.vala')
-rw-r--r-- | src/service.vala | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/service.vala b/src/service.vala index 6a3c356..6f19ed2 100644 --- a/src/service.vala +++ b/src/service.vala @@ -255,6 +255,7 @@ public class IndicatorSound.Service: Object { unowned string env = Environment.get_variable ("DESKTOP_SESSION"); unowned string xdg_desktop = Environment.get_variable ("XDG_CURRENT_DESKTOP"); string cmd; + string arg; /* FIXME: the below code needs to be moved into libayatana-common!!! */ @@ -267,18 +268,41 @@ public class IndicatorSound.Service: Object { #endif if (env == "xubuntu" || env == "xfce" || env == "ubuntustudio") + { cmd = "pavucontrol"; - else if ((env == "mate" || xdg_desktop == "MATE") && Environment.find_program_in_path ("mate-volume-control") != null) + arg = ""; + } + else if ((env == "mate" || xdg_desktop == "MATE")) + { cmd = "mate-volume-control"; - else if (desktop_is_unity() && Environment.find_program_in_path ("unity-control-center") != null) - cmd = "unity-control-center sound"; + arg = ""; + } + else if (desktop_is_unity()) + { + cmd = "unity-control-center"; + arg = "sound"; + } else - cmd = "gnome-control-center sound"; + { + cmd = "gnome-control-center"; + arg = "sound"; + } - try { - Process.spawn_command_line_async (cmd); - } catch (Error e) { - warning ("unable to launch sound settings: %s", e.message); + try + { + if (Environment.find_program_in_path(cmd) == null) + { + string command_line = "zenity --warning --icon-name=\"dialog-warning\" --title=\"%s\" --text=\"%s\" --no-wrap".printf(_("Missing application"), _("Could not find the '%s' application - please make sure it is installed.").printf(cmd)); + Process.spawn_command_line_async(command_line); + } + else + { + Process.spawn_command_line_async(cmd + " " + arg); + } + } + catch (Error e) + { + warning("unable to launch sound settings: %s", e.message); } } |