private bool IsAccessibilityEnabledDBus ()
{
// FIXME: This is a temporary hack, we will replace it, proposed solutions:
// - Use dbus-sharp, once we are using it as a
// stand-alone package rather than copying it into
// each module we use.
// Alternatively, we could use C glue with gdbus,
// but this would up the glib dependency to 2.26
// unless we dlopen.
string output = bool.FalseString;
ProcessStartInfo
processInfo = new ProcessStartInfo ("dbus-send",
"--print-reply --type=method_call --dest=org.a11y.Bus /org/a11y/bus org.freedesktop.DBus.Properties.Get string:org.a11y.Status string:IsEnabled");
processInfo.UseShellExecute = false;
processInfo.ErrorDialog = false;
processInfo.CreateNoWindow = true;
processInfo.RedirectStandardOutput = true;
processInfo.RedirectStandardError = true;
// If this throws an exception, then just let the
// caller catch it and try the old API
Process dbus_send = Process.Start (processInfo);
output = dbus_send.StandardOutput.ReadToEnd () ?? bool.FalseString;
dbus_send.WaitForExit ();
dbus_send.Close ();
if (output.Contains ("true"))
return true;
if (output.Contains ("false"))
return false;
throw new NotSupportedException ();
}