diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2015-02-16 10:33:29 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2015-02-23 09:24:21 +0100 |
commit | a80a1b6b462024db2a3d9178fbf19402f0a0ab2c (patch) | |
tree | fa405361bdc8daa8ad62d17ded80f49c91b859b6 /clients | |
parent | 758e488f13140e55581c756ebab5ed7edb716f65 (diff) | |
download | NetworkManager-a80a1b6b462024db2a3d9178fbf19402f0a0ab2c.tar.gz |
nmcli: show connection list in colors
Colorize active connections as follows:
activated - green
activating - yellow
deactivating/deactivated - red
invisible active connections - dimmed
Diffstat (limited to 'clients')
-rw-r--r-- | clients/cli/connections.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 4274abc69f..75ad308518 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -776,6 +776,7 @@ fill_output_connection (NMConnection *connection, NmCli *nmc, gboolean active_on NMActiveConnection *ac = NULL; const char *ac_path = NULL; const char *ac_state = NULL; + NMActiveConnectionState ac_state_int; char *ac_dev = NULL; s_con = nm_connection_get_setting_connection (connection); @@ -787,7 +788,8 @@ fill_output_connection (NMConnection *connection, NmCli *nmc, gboolean active_on if (ac) { ac_path = nm_object_get_path (NM_OBJECT (ac)); - ac_state = active_connection_state_to_string (nm_active_connection_get_state (ac)); + ac_state_int = nm_active_connection_get_state (ac); + ac_state = active_connection_state_to_string (ac_state_int); ac_dev = get_ac_device_string (ac); } @@ -804,6 +806,16 @@ fill_output_connection (NMConnection *connection, NmCli *nmc, gboolean active_on arr = nmc_dup_fields_array (nmc_fields_con_show, sizeof (nmc_fields_con_show), 0); + /* Show active connections in color */ + if (ac) { + if (ac_state_int == NM_ACTIVE_CONNECTION_STATE_ACTIVATING) + set_val_color_all (arr, NMC_TERM_COLOR_YELLOW); + else if (ac_state_int == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) + set_val_color_all (arr, NMC_TERM_COLOR_GREEN); + else if (ac_state_int > NM_ACTIVE_CONNECTION_STATE_ACTIVATED) + set_val_color_all (arr, NMC_TERM_COLOR_RED); + } + set_val_strc (arr, 0, nm_setting_connection_get_id (s_con)); set_val_strc (arr, 1, nm_setting_connection_get_uuid (s_con)); set_val_strc (arr, 2, nm_setting_connection_get_connection_type (s_con)); @@ -852,6 +864,8 @@ fill_output_connection_for_invisible (NMActiveConnection *ac, NmCli *nmc) set_val_strc (arr, 11, ac_state); set_val_strc (arr, 12, ac_path); + set_val_color_fmt_all (arr, NMC_TERM_FORMAT_DIM); + g_ptr_array_add (nmc->output_data, arr); } |