From fe2eddd67c0c85c22a87b685ab6265c1fb4887af Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 10 Nov 2022 12:59:51 +0100 Subject: [PATCH] nmcli/monitor: always print running status on monitor startup Previously we'd note if NM is stopped, but not if it's running. I suppose it's nice for the user to know that the monitor started running, but, it's also important for the monitor to be testable (so that we know that we are ready to start adding mock objects, etc.) This also gets rids of some duplication at expense of a little less nuanced message. --- src/nmcli/general.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/nmcli/general.c b/src/nmcli/general.c index ec18b1e20..b050d2b74 100644 --- a/src/nmcli/general.c +++ b/src/nmcli/general.c @@ -1233,7 +1233,7 @@ networkmanager_running(NMClient *client, GParamSpec *param, NmCli *nmc) running = nm_client_get_nm_running(client); str = nmc_colorize(&nmc->nmc_config, running ? NM_META_COLOR_MANAGER_RUNNING : NM_META_COLOR_MANAGER_STOPPED, - running ? _("NetworkManager has started") : _("NetworkManager has stopped")); + running ? _("NetworkManager is running") : _("NetworkManager is stopped")); g_print("%s\n", str); g_free(str); } @@ -1613,15 +1613,7 @@ nmc_command_func_monitor(const NMCCommand *cmd, NmCli *nmc, int argc, const char return; } - if (!nm_client_get_nm_running(nmc->client)) { - char *str; - - str = nmc_colorize(&nmc->nmc_config, - NM_META_COLOR_MANAGER_STOPPED, - _("Networkmanager is not running (waiting for it)\n")); - g_print("%s", str); - g_free(str); - } + networkmanager_running(nmc->client, NULL, nmc); g_signal_connect(nmc->client, "notify::" NM_CLIENT_NM_RUNNING,