From 45bde614f382f0e0fc8777cd95b94e7e77b5fba0 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Fri, 12 Mar 2021 11:33:36 +0100 Subject: src/service.vala: Display a zenity warning if the audio settings application is not found fixes #12 --- src/service.vala | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'src') 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); } } -- cgit v1.2.3