From 1a7b6d4a6b39f743419027552ab573ae4a3c91dd Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Mon, 22 Jul 2024 08:51:29 +1000 Subject: [PATCH] Separate htoprc for htop and pcp-htop to prevent overwrite The original intention with pcp-htop was to share the same htoprc configuration file with regular htop. However this also stores tab configuration which causes confusion since the default pcp-htop tab set is unintentionally reduced to match the defaults on Linux (when htop is invoked prior to pcp-htop). Relates to issue #952. --- Settings.c | 6 +++--- configure.ac | 13 +++++++++++++ htop.1.in | 23 +++++++++++++++++------ pcp/PCPDynamicColumn.c | 2 +- pcp/PCPDynamicMeter.c | 2 +- pcp/PCPDynamicScreen.c | 2 +- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/Settings.c b/Settings.c index 5913af27a..f8fbcb19c 100644 --- a/Settings.c +++ b/Settings.c @@ -874,9 +874,9 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicMeters, H configDir = xStrdup(xdgConfigHome); htopDir = String_cat(xdgConfigHome, "/htop"); } else { - this->initialFilename = String_cat(home, "/.config/htop/htoprc"); - configDir = String_cat(home, "/.config"); - htopDir = String_cat(home, "/.config/htop"); + this->initialFilename = String_cat(home, CONFIGDIR "/htop/htoprc"); + configDir = String_cat(home, CONFIGDIR); + htopDir = String_cat(home, CONFIGDIR "/htop"); } (void) mkdir(configDir, 0700); (void) mkdir(htopDir, 0700); diff --git a/configure.ac b/configure.ac index b1e2e9c08..dfa3e2946 100644 --- a/configure.ac +++ b/configure.ac @@ -599,6 +599,19 @@ if test -n "$with_os_release" && test ! -f "$with_os_release"; then fi AC_DEFINE_UNQUOTED([OSRELEASEFILE], ["$with_os_release"], [File with OS release details.]) +AC_ARG_WITH([config], + [AS_HELP_STRING([--with-config=DIR], + [configuration path @<:@default=/.config@:>@])], + [], + [with_config="/.config"]) +dnl Performance Co-Pilot configuration location to prevent overwrite +if test "$my_htop_platform" = pcp -a "$with_config" = /.config; then + with_config="/.pcp" +elif test -z "$with_config"; then + AC_MSG_ERROR([bad empty value for --with-config option]) +fi +AC_DEFINE_UNQUOTED([CONFIGDIR], ["$with_config"], [Configuration path.]) + # ---------------------------------------------------------------------- diff --git a/htop.1.in b/htop.1.in index ad7a4ba3e..1dbfc4ee1 100644 --- a/htop.1.in +++ b/htop.1.in @@ -619,12 +619,23 @@ The .B pcp-htop utility makes use of .I htoprc -in exactly the same way. -In addition, it supports additional configuration files allowing -new meters and columns to be added to the display via the usual -Setup function, which will display additional Available Meters -and Available Column entries for each runtime configured meter -or column. +in a similar way. +However, +.B pcp-htop +reads its configuration from a path more conventionally used by +Performance Co-Pilot tools, +.IR ~/.pcp/htop/htoprc , +in order to provide separate configuration when both +.B htop +and +.B pcp-htop +are installed and in use. +.B pcp-htop +supports additional configuration files below the same directory +allowing new meters, columns and screen tabs to be added via the +Setup screen (F2). +This displays additional Available Meters, Available Column and +Screen Tabs for each meter, column or screen configuration file. .LP These .B pcp-htop diff --git a/pcp/PCPDynamicColumn.c b/pcp/PCPDynamicColumn.c index b0bd03e1b..b2ebe985a 100644 --- a/pcp/PCPDynamicColumn.c +++ b/pcp/PCPDynamicColumn.c @@ -230,7 +230,7 @@ void PCPDynamicColumns_init(PCPDynamicColumns* columns) { if (xdgConfigHome) path = String_cat(xdgConfigHome, "/htop/columns/"); else if (home) - path = String_cat(home, "/.config/htop/columns/"); + path = String_cat(home, CONFIGDIR "/htop/columns/"); else path = NULL; if (path) { diff --git a/pcp/PCPDynamicMeter.c b/pcp/PCPDynamicMeter.c index 11df5f0a4..5fe96ae4d 100644 --- a/pcp/PCPDynamicMeter.c +++ b/pcp/PCPDynamicMeter.c @@ -273,7 +273,7 @@ void PCPDynamicMeters_init(PCPDynamicMeters* meters) { if (xdgConfigHome) path = String_cat(xdgConfigHome, "/htop/meters/"); else if (home) - path = String_cat(home, "/.config/htop/meters/"); + path = String_cat(home, CONFIGDIR "/htop/meters/"); else path = NULL; if (path) { diff --git a/pcp/PCPDynamicScreen.c b/pcp/PCPDynamicScreen.c index 22228225d..281722fac 100644 --- a/pcp/PCPDynamicScreen.c +++ b/pcp/PCPDynamicScreen.c @@ -307,7 +307,7 @@ void PCPDynamicScreens_init(PCPDynamicScreens* screens, PCPDynamicColumns* colum if (xdgConfigHome) path = String_cat(xdgConfigHome, "/htop/screens/"); else if (home) - path = String_cat(home, "/.config/htop/screens/"); + path = String_cat(home, CONFIGDIR "/htop/screens/"); else path = NULL; if (path) {