From 352c9695f3def99571fed7f188e1546fcfae2784 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 10 Feb 2022 14:06:30 +0100 Subject: [PATCH] shell: Add call to check the existence of a systemd unit These checks will be handy while handling ibus-daemon startup, since this is going to move to a systemd service soon. Part-of: --- src/shell-util.c | 19 +++++++++++++++++++ src/shell-util.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/src/shell-util.c b/src/shell-util.c index 4a53a7c99..a33686813 100644 --- a/src/shell-util.c +++ b/src/shell-util.c @@ -787,6 +787,25 @@ shell_util_stop_systemd_unit_finish (GAsyncResult *res, return g_task_propagate_boolean (G_TASK (res), error); } +void +shell_util_systemd_unit_exists (const gchar *unit, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + shell_util_systemd_call ("GetUnit", + g_variant_new ("(s)", unit), + SYSTEMD_CALL_FLAGS_NONE, + cancellable, callback, user_data); +} + +gboolean +shell_util_systemd_unit_exists_finish (GAsyncResult *res, + GError **error) +{ + return g_task_propagate_boolean (G_TASK (res), error); +} + void shell_util_sd_notify (void) { diff --git a/src/shell-util.h b/src/shell-util.h index 04485b99c..7e1f7d88c 100644 --- a/src/shell-util.h +++ b/src/shell-util.h @@ -72,6 +72,13 @@ void shell_util_stop_systemd_unit (const char *unit, gboolean shell_util_stop_systemd_unit_finish (GAsyncResult *res, GError **error); +void shell_util_systemd_unit_exists (const gchar *unit, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean shell_util_systemd_unit_exists_finish (GAsyncResult *res, + GError **error); + void shell_util_sd_notify (void); gboolean shell_util_has_x11_display_extension (MetaDisplay *display,