Skip to content

Commit

Permalink
Add setting to show only active CPUs
Browse files Browse the repository at this point in the history
Closes: htop-dev#757
  • Loading branch information
cgzones committed Aug 21, 2021
1 parent a9ddacc commit 4a014ad
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CPUMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static void AllCPUsMeter_updateValues(Meter* this) {
}

static void CPUMeterCommonInit(Meter* this, int ncol) {
unsigned int cpus = this->pl->existingCPUs;
unsigned int cpus = this->pl->settings->showOnlyActiveCPUs ? this->pl->activeCPUs : this->pl->existingCPUs;
CPUMeterData* data = this->meterData;
if (!data) {
data = this->meterData = xMalloc(sizeof(CPUMeterData));
Expand Down
1 change: 1 addition & 0 deletions DisplayOptionsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
Panel_add(super, (Object*) CheckItem_newByRef("Leave a margin around header", &(settings->headerMargin)));
Panel_add(super, (Object*) CheckItem_newByRef("Detailed CPU time (System/IO-Wait/Hard-IRQ/Soft-IRQ/Steal/Guest)", &(settings->detailedCPUTime)));
Panel_add(super, (Object*) CheckItem_newByRef("Count CPUs from 1 instead of 0", &(settings->countCPUsFromOne)));
Panel_add(super, (Object*) CheckItem_newByRef("Show only active CPUs", &(settings->showOnlyActiveCPUs)));
Panel_add(super, (Object*) CheckItem_newByRef("Update process names on every refresh", &(settings->updateProcessNames)));
Panel_add(super, (Object*) CheckItem_newByRef("Add guest time in CPU meter percentage", &(settings->accountGuestInCPUMeter)));
Panel_add(super, (Object*) CheckItem_newByRef("Also show CPU percentage numerically", &(settings->showCPUUsage)));
Expand Down
4 changes: 4 additions & 0 deletions Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
} else if (String_eq(option[0], "cpu_count_from_zero")) {
// old (inverted) naming also supported for backwards compatibility
this->countCPUsFromOne = !atoi(option[1]);
} else if (String_eq(option[0], "show_only_active_cpu")) {
this->showOnlyActiveCPUs = atoi(option[1]);
} else if (String_eq(option[0], "show_cpu_usage")) {
this->showCPUUsage = atoi(option[1]);
} else if (String_eq(option[0], "show_cpu_frequency")) {
Expand Down Expand Up @@ -352,6 +354,7 @@ int Settings_write(const Settings* this, bool onCrash) {
fprintf(fd, "header_margin=%d\n", (int) this->headerMargin);
fprintf(fd, "detailed_cpu_time=%d\n", (int) this->detailedCPUTime);
fprintf(fd, "cpu_count_from_one=%d\n", (int) this->countCPUsFromOne);
fprintf(fd, "show_only_active_cpu=%d\n", (int) this->showOnlyActiveCPUs);
fprintf(fd, "show_cpu_usage=%d\n", (int) this->showCPUUsage);
fprintf(fd, "show_cpu_frequency=%d\n", (int) this->showCPUFrequency);
#ifdef BUILD_WITH_CPU_TEMP
Expand Down Expand Up @@ -407,6 +410,7 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicColumns)
this->highlightMegabytes = true;
this->detailedCPUTime = false;
this->countCPUsFromOne = false;
this->showOnlyActiveCPUs = false;
this->showCPUUsage = true;
this->showCPUFrequency = false;
#ifdef BUILD_WITH_CPU_TEMP
Expand Down
1 change: 1 addition & 0 deletions Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ typedef struct Settings_ {
ProcessField treeSortKey;

bool countCPUsFromOne;
bool showOnlyActiveCPUs;
bool detailedCPUTime;
bool showCPUUsage;
bool showCPUFrequency;
Expand Down

0 comments on commit 4a014ad

Please sign in to comment.