Skip to content

Commit 0847432

Browse files
committed
CPUUsage: rename cpuusage-display-type to separate
1 parent e297144 commit 0847432

File tree

5 files changed

+22
-28
lines changed

5 files changed

+22
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Features:
55
* Support GNOME Console terminal version and font detection (Terminal, Linux)
66
* Add `--cpu-freq-ndigits` to set number of digits for CPU frequency (CPU)
77
* New module to detect physical disk I/O usage (DiskIO)
8+
* Add `--cpuusage-separate` to display CPU usage per CPU logical core
89

910
Bugfixes:
1011
* Fix possible crashes on Windows 7 (Disk, Windows)

doc/json_schema.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,6 @@
631631
"const": "chassis",
632632
"description": "Print chassis type (desktop, laptop, etc)"
633633
},
634-
{
635-
"const": "cpuusage",
636-
"description": "Print CPU usage. Costs some time to collect data"
637-
},
638634
{
639635
"const": "cursor",
640636
"description": "Print cursor style name"
@@ -876,6 +872,20 @@
876872
},
877873
"additionalProperties": false
878874
},
875+
{
876+
"title": "CPU Usage",
877+
"properties": {
878+
"type": {
879+
"const": "cpuusage",
880+
"description": "Print CPU usage. Costs some time to collect data"
881+
},
882+
"separate": {
883+
"type": "boolean",
884+
"description": "Display CPU usage per CPU logical core, instead of an average result",
885+
"default": false
886+
}
887+
}
888+
},
879889
{
880890
"title": "Colors",
881891
"properties": {

src/data/help.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ Module specific options:
141141
--battery-dir <folder>: The directory where the battery folders are. Standard: /sys/class/power_supply/
142142
--cpu-temp <?value>: Detect and display CPU temperature if supported. Default is false
143143
--cpu-freq-ndigits <num>: Set the number of digits to keep after the decimal point when printing CPU frequency. Default is 2
144+
--cpuusage-separate <?value>: Display CPU usage per CPU logical core, instead of an average result. Default is false
144145
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
145146
--gpu-force-vulkan <?value>: Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`. Default is false
146147
--gpu-hide-type <?value>: Specify the type of GPUs should not be printed. Must be `integrated`, `discrete` or `none`. Default is none

src/modules/cpuusage/cpuusage.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
4545
ffPrintLogoAndKey(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
4646

4747
FF_STRBUF_AUTO_DESTROY str = ffStrbufCreate();
48-
if (options->displayType == FF_CPUUSAGE_DISPLAY_TYPE_DEFAULT)
48+
if (!options->separate)
4949
{
5050
if(instance.config.percentType & FF_PERCENTAGE_TYPE_BAR_BIT)
5151
ffAppendPercentBar(&str, avgValue, 0, 50, 80);
@@ -98,13 +98,9 @@ bool ffParseCPUUsageCommandOptions(FFCPUUsageOptions* options, const char* key,
9898
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
9999
return true;
100100

101-
if (ffStrEqualsIgnCase(subKey, "display-type"))
101+
if (ffStrEqualsIgnCase(subKey, "separate"))
102102
{
103-
options->displayType = (FFCPUUsageDisplayType) ffOptionParseEnum(key, value, (FFKeyValuePair[]) {
104-
{ "default", FF_CPUUSAGE_DISPLAY_TYPE_DEFAULT },
105-
{ "separate", FF_CPUUSAGE_DISPLAY_TYPE_SEPARATE },
106-
{},
107-
});
103+
options->separate = ffOptionParseBoolean(value);
108104
return true;
109105
}
110106

@@ -129,18 +125,9 @@ void ffParseCPUUsageJsonObject(FFCPUUsageOptions* options, yyjson_val* module)
129125
if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs))
130126
continue;
131127

132-
if (ffStrEqualsIgnCase(key, "display-type"))
128+
if (ffStrEqualsIgnCase(key, "separate"))
133129
{
134-
int value;
135-
const char* error = ffJsonConfigParseEnum(val, &value, (FFKeyValuePair[]) {
136-
{ "default", FF_CPUUSAGE_DISPLAY_TYPE_DEFAULT },
137-
{ "separate", FF_CPUUSAGE_DISPLAY_TYPE_SEPARATE },
138-
{},
139-
});
140-
if (error)
141-
ffPrintErrorString(FF_CPUUSAGE_MODULE_NAME, 0, NULL, FF_PRINT_TYPE_NO_CUSTOM_KEY, "Invalid %s value: %s", key, error);
142-
else
143-
options->displayType = (FFCPUUsageDisplayType) value;
130+
options->separate = yyjson_get_bool(val);
144131
continue;
145132
}
146133

src/modules/cpuusage/option.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@
44

55
#include "common/option.h"
66

7-
typedef enum FFCPUUsageDisplayType {
8-
FF_CPUUSAGE_DISPLAY_TYPE_DEFAULT,
9-
FF_CPUUSAGE_DISPLAY_TYPE_SEPARATE,
10-
} FFCPUUsageDisplayType;
11-
127
typedef struct FFCPUUsageOptions
138
{
149
FFModuleBaseInfo moduleInfo;
1510
FFModuleArgs moduleArgs;
1611

17-
FFCPUUsageDisplayType displayType;
12+
bool separate;
1813
} FFCPUUsageOptions;

0 commit comments

Comments
 (0)