From 6a0a87541f609ece7f02306951e103868ca321ac Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Wed, 5 Jun 2024 18:33:37 +0200 Subject: [PATCH] nmcli/dev: check killswitch state one "nmcli d wifi list" If someone flips a kill switch by accident (or intoxicated), figuring out why "nmcli d wifi list" output is empty is a bit of a head scratcher. Make it a bit more obvious, that listing networks makes no sense without the radios being enabled. --- src/nmcli/devices.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c index a3ea7c454f..81edfd2724 100644 --- a/src/nmcli/devices.c +++ b/src/nmcli/devices.c @@ -3527,6 +3527,21 @@ do_device_wifi_list(const NMCCommand *cmd, NmCli *nmc, int argc, const char *con return; } + if (!nm_client_wireless_hardware_get_enabled(nmc->client)) { + nmc_print(_("Hint: \"nmcli radio\" shows the radio state.\n")); + g_string_printf(nmc->return_text, + _("Error: Wi-Fi radio is disabled by airplane mode switch.")); + nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND; + return; + } + + if (!nm_client_wireless_get_enabled(nmc->client)) { + nmc_print(_("Hint: \"nmcli radio wifi on\" enables the Wi-Fi radio.\n")); + g_string_printf(nmc->return_text, _("Error: Wi-Fi radio is disabled by software.")); + nmc->return_value = NMC_RESULT_ERROR_NOT_FOUND; + return; + } + scan_info = g_slice_new(ScanInfo); *scan_info = (ScanInfo){ .out_indices = g_array_ref(out_indices),