diff --git a/doc/config_settings.xml b/doc/config_settings.xml index 26c4db99..70fd0b82 100644 --- a/doc/config_settings.xml +++ b/doc/config_settings.xml @@ -959,6 +959,17 @@ of all processors' power combined. + + + + + + + If true, top name shows the full command line of each + process, including arguments (whenever possible). Otherwise, + only the basename is displayed. Default value is false. + + diff --git a/src/top.cc b/src/top.cc index abe4535a..04cf4050 100644 --- a/src/top.cc +++ b/src/top.cc @@ -32,6 +32,7 @@ #include "prioqueue.h" #include "top.h" #include "logging.h" +#include /* hash table size - always a power of 2 */ #define HTABSIZE 256 @@ -480,6 +481,7 @@ struct top_data { static conky::range_config_setting top_name_width("top_name_width", 0, std::numeric_limits::max(), 15, true); +static conky::simple_config_setting top_name_verbose("top_name_verbose", false, false); static void print_top_name(struct text_object *obj, char *p, int p_max_size) { @@ -489,8 +491,13 @@ static void print_top_name(struct text_object *obj, char *p, int p_max_size) if (!td || !td->list || !td->list[td->num]) return; + std::string top_name = td->list[td->num]->name; + if (!top_name_verbose.get(*state)) { + top_name = top_name.substr(0, top_name.find_first_of(' ')); + } + width = MIN(p_max_size, (int)top_name_width.get(*state) + 1); - snprintf(p, width + 1, "%-*s", width, td->list[td->num]->name); + snprintf(p, width + 1, "%-*s", width, top_name.c_str()); } static void print_top_mem(struct text_object *obj, char *p, int p_max_size)