Skip to content

Commit 545267b

Browse files
committed
Percentage: support percent bar in custom formatting
Fix #1075
1 parent 789f1e3 commit 545267b

File tree

9 files changed

+106
-57
lines changed

9 files changed

+106
-57
lines changed

src/modules/battery/battery.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "modules/battery/battery.h"
88
#include "util/stringUtils.h"
99

10-
#define FF_BATTERY_NUM_FORMAT_ARGS 9
10+
#define FF_BATTERY_NUM_FORMAT_ARGS 10
1111

1212
static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uint8_t index)
1313
{
@@ -57,20 +57,23 @@ static void printBattery(FFBatteryOptions* options, FFBatteryResult* result, uin
5757
}
5858
else
5959
{
60-
FF_STRBUF_AUTO_DESTROY capacityStr = ffStrbufCreate();
61-
ffPercentAppendNum(&capacityStr, result->capacity, options->percent, false, &options->moduleArgs);
60+
FF_STRBUF_AUTO_DESTROY capacityNum = ffStrbufCreate();
61+
ffPercentAppendNum(&capacityNum, result->capacity, options->percent, false, &options->moduleArgs);
62+
FF_STRBUF_AUTO_DESTROY capacityBar = ffStrbufCreate();
63+
ffPercentAppendBar(&capacityBar, result->capacity, options->percent, &options->moduleArgs);
6264
FF_STRBUF_AUTO_DESTROY tempStr = ffStrbufCreate();
6365
ffTempsAppendNum(result->temperature, &tempStr, options->tempConfig, &options->moduleArgs);
6466
FF_PRINT_FORMAT_CHECKED(FF_BATTERY_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BATTERY_NUM_FORMAT_ARGS, ((FFformatarg[]) {
6567
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufacturer, "manufacturer"},
6668
{FF_FORMAT_ARG_TYPE_STRBUF, &result->modelName, "model-name"},
6769
{FF_FORMAT_ARG_TYPE_STRBUF, &result->technology, "technology"},
68-
{FF_FORMAT_ARG_TYPE_STRBUF, &capacityStr, "capacity"},
70+
{FF_FORMAT_ARG_TYPE_STRBUF, &capacityNum, "capacity"},
6971
{FF_FORMAT_ARG_TYPE_STRBUF, &result->status, "status"},
7072
{FF_FORMAT_ARG_TYPE_STRBUF, &tempStr, "temperature"},
7173
{FF_FORMAT_ARG_TYPE_UINT, &result->cycleCount, "cycle-count"},
7274
{FF_FORMAT_ARG_TYPE_STRBUF, &result->serial, "serial"},
7375
{FF_FORMAT_ARG_TYPE_STRBUF, &result->manufactureDate, "manufacture-date"},
76+
{FF_FORMAT_ARG_TYPE_STRBUF, &capacityBar, "capacity-bar"},
7477
}));
7578
}
7679
}
@@ -225,12 +228,13 @@ void ffPrintBatteryHelpFormat(void)
225228
"Battery manufacturer - manufacturer",
226229
"Battery model name - model-name",
227230
"Battery technology - technology",
228-
"Battery capacity (percentage) - capacity",
231+
"Battery capacity (percentage num) - capacity",
229232
"Battery status - status",
230233
"Battery temperature (formatted) - temperature",
231234
"Battery cycle count - cycle-count",
232235
"Battery serial number - serial",
233236
"Battery manufactor date - manufacture-date",
237+
"Battery capacity (percentage bar) - capacity-bar",
234238
}));
235239
}
236240

src/modules/bluetooth/bluetooth.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "modules/bluetooth/bluetooth.h"
66
#include "util/stringUtils.h"
77

8-
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 5
8+
#define FF_BLUETOOTH_NUM_FORMAT_ARGS 6
99

1010
static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* device, uint8_t index)
1111
{
@@ -29,15 +29,18 @@ static void printDevice(FFBluetoothOptions* options, const FFBluetoothResult* de
2929
}
3030
else
3131
{
32-
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
33-
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false, &options->moduleArgs);
32+
FF_STRBUF_AUTO_DESTROY percentageNum = ffStrbufCreate();
33+
ffPercentAppendNum(&percentageNum, device->battery, options->percent, false, &options->moduleArgs);
34+
FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate();
35+
ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs);
3436

3537
FF_PRINT_FORMAT_CHECKED(FF_BLUETOOTH_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_BLUETOOTH_NUM_FORMAT_ARGS, ((FFformatarg[]) {
3638
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"},
3739
{FF_FORMAT_ARG_TYPE_STRBUF, &device->address, "address"},
3840
{FF_FORMAT_ARG_TYPE_STRBUF, &device->type, "type"},
39-
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr, "battery-percentage"},
41+
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageNum, "battery-percentage"},
4042
{FF_FORMAT_ARG_TYPE_BOOL, &device->connected, "connected"},
43+
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageBar, "battery-percentage-bar"},
4144
}));
4245
}
4346
}
@@ -178,8 +181,9 @@ void ffPrintBluetoothHelpFormat(void)
178181
"Name - name",
179182
"Address - address",
180183
"Type - type",
181-
"Battery percentage - battery-percentage",
184+
"Battery percentage number - battery-percentage",
182185
"Is connected - connected",
186+
"Battery percentage bar - battery-percentage-bar",
183187
}));
184188
}
185189

src/modules/brightness/brightness.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "modules/brightness/brightness.h"
66
#include "util/stringUtils.h"
77

8-
#define FF_BRIGHTNESS_NUM_FORMAT_ARGS 5
8+
#define FF_BRIGHTNESS_NUM_FORMAT_ARGS 6
99

1010
void ffPrintBrightness(FFBrightnessOptions* options)
1111
{
@@ -67,14 +67,17 @@ void ffPrintBrightness(FFBrightnessOptions* options)
6767
}
6868
else
6969
{
70-
FF_STRBUF_AUTO_DESTROY valueStr = ffStrbufCreate();
71-
ffPercentAppendNum(&valueStr, percent, options->percent, false, &options->moduleArgs);
70+
FF_STRBUF_AUTO_DESTROY valueNum = ffStrbufCreate();
71+
ffPercentAppendNum(&valueNum, percent, options->percent, false, &options->moduleArgs);
72+
FF_STRBUF_AUTO_DESTROY valueBar = ffStrbufCreate();
73+
ffPercentAppendBar(&valueBar, percent, options->percent, &options->moduleArgs);
7274
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((FFformatarg[]) {
73-
{FF_FORMAT_ARG_TYPE_STRBUF, &valueStr, "percentage"},
75+
{FF_FORMAT_ARG_TYPE_STRBUF, &valueNum, "percentage"},
7476
{FF_FORMAT_ARG_TYPE_STRBUF, &item->name, "name"},
7577
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->max, "max"},
7678
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->min, "min"},
7779
{FF_FORMAT_ARG_TYPE_DOUBLE, &item->current, "current"},
80+
{FF_FORMAT_ARG_TYPE_STRBUF, &item->current, "percentage-bar"},
7881
}));
7982
}
8083

@@ -175,11 +178,12 @@ void ffGenerateBrightnessJsonResult(FF_MAYBE_UNUSED FFBrightnessOptions* options
175178
void ffPrintBrightnessHelpFormat(void)
176179
{
177180
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_BRIGHTNESS_MODULE_NAME, "{1}", FF_BRIGHTNESS_NUM_FORMAT_ARGS, ((const char* []) {
178-
"Screen brightness (percentage) - percentage",
181+
"Screen brightness (percentage num) - percentage",
179182
"Screen name - name",
180183
"Maximum brightness value - max",
181184
"Minimum brightness value - min",
182185
"Current brightness value - current",
186+
"Screen brightness (percentage bar) - percentage-bar",
183187
}));
184188
}
185189

src/modules/cpuusage/cpuusage.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "util/stringUtils.h"
77

88
#define FF_CPUUSAGE_DISPLAY_NAME "CPU Usage"
9-
#define FF_CPUUSAGE_NUM_FORMAT_ARGS 5
9+
#define FF_CPUUSAGE_NUM_FORMAT_ARGS 8
1010

1111
void ffPrintCPUUsage(FFCPUUsageOptions* options)
1212
{
@@ -73,18 +73,27 @@ void ffPrintCPUUsage(FFCPUUsageOptions* options)
7373
}
7474
else
7575
{
76-
FF_STRBUF_AUTO_DESTROY avgStr = ffStrbufCreate();
77-
ffPercentAppendNum(&avgStr, avgValue, options->percent, false, &options->moduleArgs);
78-
FF_STRBUF_AUTO_DESTROY minStr = ffStrbufCreate();
79-
ffPercentAppendNum(&minStr, minValue, options->percent, false, &options->moduleArgs);
80-
FF_STRBUF_AUTO_DESTROY maxStr = ffStrbufCreate();
81-
ffPercentAppendNum(&maxStr, maxValue, options->percent, false, &options->moduleArgs);
76+
FF_STRBUF_AUTO_DESTROY avgNum = ffStrbufCreate();
77+
ffPercentAppendNum(&avgNum, avgValue, options->percent, false, &options->moduleArgs);
78+
FF_STRBUF_AUTO_DESTROY avgBar = ffStrbufCreate();
79+
ffPercentAppendBar(&avgBar, avgValue, options->percent, &options->moduleArgs);
80+
FF_STRBUF_AUTO_DESTROY minNum = ffStrbufCreate();
81+
ffPercentAppendNum(&minNum, minValue, options->percent, false, &options->moduleArgs);
82+
FF_STRBUF_AUTO_DESTROY minBar = ffStrbufCreate();
83+
ffPercentAppendBar(&minBar, minValue, options->percent, &options->moduleArgs);
84+
FF_STRBUF_AUTO_DESTROY maxNum = ffStrbufCreate();
85+
ffPercentAppendNum(&maxNum, maxValue, options->percent, false, &options->moduleArgs);
86+
FF_STRBUF_AUTO_DESTROY maxBar = ffStrbufCreate();
87+
ffPercentAppendBar(&maxBar, maxValue, options->percent, &options->moduleArgs);
8288
FF_PRINT_FORMAT_CHECKED(FF_CPUUSAGE_DISPLAY_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_CPUUSAGE_NUM_FORMAT_ARGS, ((FFformatarg[]){
83-
{FF_FORMAT_ARG_TYPE_STRBUF, &avgStr, "avg"},
84-
{FF_FORMAT_ARG_TYPE_STRBUF, &maxStr, "max"},
89+
{FF_FORMAT_ARG_TYPE_STRBUF, &avgNum, "avg"},
90+
{FF_FORMAT_ARG_TYPE_STRBUF, &maxNum, "max"},
8591
{FF_FORMAT_ARG_TYPE_UINT, &maxIndex, "max-index"},
86-
{FF_FORMAT_ARG_TYPE_STRBUF, &minStr, "min"},
92+
{FF_FORMAT_ARG_TYPE_STRBUF, &minNum, "min"},
8793
{FF_FORMAT_ARG_TYPE_UINT, &minIndex, "min-index"},
94+
{FF_FORMAT_ARG_TYPE_STRBUF, &avgBar, "avg-bar"},
95+
{FF_FORMAT_ARG_TYPE_STRBUF, &maxBar, "max-bar"},
96+
{FF_FORMAT_ARG_TYPE_STRBUF, &minBar, "min-bar"},
8897
}));
8998
}
9099
}
@@ -167,11 +176,14 @@ void ffGenerateCPUUsageJsonResult(FF_MAYBE_UNUSED FFCPUUsageOptions* options, yy
167176
void ffPrintCPUUsageHelpFormat(void)
168177
{
169178
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_CPUUSAGE_MODULE_NAME, "{1}", FF_CPUUSAGE_NUM_FORMAT_ARGS, ((const char* []) {
170-
"CPU usage (percentage, average) - avg",
171-
"CPU usage (percentage, maximum) - max",
179+
"CPU usage (percentage num, average) - avg",
180+
"CPU usage (percentage num, maximum) - max",
172181
"CPU core index of maximum usage - max-index",
173-
"CPU usage (percentage, minimum) - min",
182+
"CPU usage (percentage num, minimum) - min",
174183
"CPU core index of minimum usage - min-index",
184+
"CPU usage (percentage bar, average) - avg-bar",
185+
"CPU usage (percentage bar, maximum) - max-bar",
186+
"CPU usage (percentage bar, minimum) - min-bar",
175187
}));
176188
}
177189

src/modules/disk/disk.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "modules/disk/disk.h"
88
#include "util/stringUtils.h"
99

10-
#define FF_DISK_NUM_FORMAT_ARGS 12
10+
#define FF_DISK_NUM_FORMAT_ARGS 14
1111
#pragma GCC diagnostic ignored "-Wsign-conversion"
1212

1313
static void printDisk(FFDiskOptions* options, const FFDisk* disk)
@@ -104,11 +104,16 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
104104
}
105105
else
106106
{
107-
FF_STRBUF_AUTO_DESTROY bytesPercentageStr = ffStrbufCreate();
108-
ffPercentAppendNum(&bytesPercentageStr, bytesPercentage, options->percent, false, &options->moduleArgs);
109-
FF_STRBUF_AUTO_DESTROY filesPercentageStr = ffStrbufCreate();
107+
FF_STRBUF_AUTO_DESTROY bytesPercentageNum = ffStrbufCreate();
108+
ffPercentAppendNum(&bytesPercentageNum, bytesPercentage, options->percent, false, &options->moduleArgs);
109+
FF_STRBUF_AUTO_DESTROY bytesPercentageBar = ffStrbufCreate();
110+
ffPercentAppendBar(&bytesPercentageBar, bytesPercentage, options->percent, &options->moduleArgs);
111+
110112
double filesPercentage = disk->filesTotal > 0 ? ((double) disk->filesUsed / (double) disk->filesTotal) * 100.0 : 0;
111-
ffPercentAppendNum(&filesPercentageStr, filesPercentage, options->percent, false, &options->moduleArgs);
113+
FF_STRBUF_AUTO_DESTROY filesPercentageNum = ffStrbufCreate();
114+
ffPercentAppendNum(&filesPercentageNum, filesPercentage, options->percent, false, &options->moduleArgs);
115+
FF_STRBUF_AUTO_DESTROY filesPercentageBar = ffStrbufCreate();
116+
ffPercentAppendBar(&filesPercentageBar, filesPercentage, options->percent, &options->moduleArgs);
112117

113118
bool isExternal = !!(disk->type & FF_DISK_VOLUME_TYPE_EXTERNAL_BIT);
114119
bool isHidden = !!(disk->type & FF_DISK_VOLUME_TYPE_HIDDEN_BIT);
@@ -117,16 +122,18 @@ static void printDisk(FFDiskOptions* options, const FFDisk* disk)
117122
FF_PRINT_FORMAT_CHECKED(key.chars, 0, &options->moduleArgs, FF_PRINT_TYPE_NO_CUSTOM_KEY, FF_DISK_NUM_FORMAT_ARGS, ((FFformatarg[]) {
118123
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty, "size-used"},
119124
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty, "size-total"},
120-
{FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageStr, "size-percentage"},
125+
{FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageNum, "size-percentage"},
121126
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesUsed, "files-used"},
122127
{FF_FORMAT_ARG_TYPE_UINT, &disk->filesTotal, "files-total"},
123-
{FF_FORMAT_ARG_TYPE_STRBUF, &filesPercentageStr, "files-percentage"},
128+
{FF_FORMAT_ARG_TYPE_STRBUF, &filesPercentageNum, "files-percentage"},
124129
{FF_FORMAT_ARG_TYPE_BOOL, &isExternal, "is-external"},
125130
{FF_FORMAT_ARG_TYPE_BOOL, &isHidden, "is-hidden"},
126131
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->filesystem, "filesystem"},
127132
{FF_FORMAT_ARG_TYPE_STRBUF, &disk->name, "name"},
128133
{FF_FORMAT_ARG_TYPE_BOOL, &isReadOnly, "is-readonly"},
129134
{FF_FORMAT_ARG_TYPE_STRING, ffTimeToShortStr(disk->createTime), "create-time"},
135+
{FF_FORMAT_ARG_TYPE_STRBUF, &bytesPercentageBar, "size-percentage-bar"},
136+
{FF_FORMAT_ARG_TYPE_STRBUF, &filesPercentageBar, "files-percentage-bar"},
130137
}));
131138
}
132139
}
@@ -430,16 +437,18 @@ void ffPrintDiskHelpFormat(void)
430437
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_DISK_MODULE_NAME, "{1} / {2} ({3}) - {9}", FF_DISK_NUM_FORMAT_ARGS, ((const char* []) {
431438
"Size used - size-used",
432439
"Size total - size-total",
433-
"Size percentage - size-percentage",
440+
"Size percentage num - size-percentage",
434441
"Files used - files-used",
435442
"Files total - files-total",
436-
"Files percentage - files-percentage",
443+
"Files percentage num - files-percentage",
437444
"True if external volume - is-external",
438445
"True if hidden volume - is-hidden",
439446
"Filesystem - filesystem",
440447
"Label / name - name",
441448
"True if read-only - is-readonly",
442449
"Create time in local timezone - create-time",
450+
"Size percentage bar - size-percentage-bar",
451+
"Files percentage bar - files-percentage-bar",
443452
}));
444453
}
445454

src/modules/gamepad/gamepad.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "modules/gamepad/gamepad.h"
66
#include "util/stringUtils.h"
77

8-
#define FF_GAMEPAD_NUM_FORMAT_ARGS 3
8+
#define FF_GAMEPAD_NUM_FORMAT_ARGS 4
99

1010
static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device, uint8_t index)
1111
{
@@ -25,13 +25,16 @@ static void printDevice(FFGamepadOptions* options, const FFGamepadDevice* device
2525
}
2626
else
2727
{
28-
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
29-
ffPercentAppendNum(&percentageStr, device->battery, options->percent, false, &options->moduleArgs);
28+
FF_STRBUF_AUTO_DESTROY percentageNum = ffStrbufCreate();
29+
ffPercentAppendNum(&percentageNum, device->battery, options->percent, false, &options->moduleArgs);
30+
FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate();
31+
ffPercentAppendBar(&percentageBar, device->battery, options->percent, &options->moduleArgs);
3032

3133
FF_PRINT_FORMAT_CHECKED(FF_GAMEPAD_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_GAMEPAD_NUM_FORMAT_ARGS, ((FFformatarg[]) {
3234
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"},
3335
{FF_FORMAT_ARG_TYPE_STRBUF, &device->serial, "serial"},
34-
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr, "battery-percentage"},
36+
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageNum, "battery-percentage"},
37+
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageBar, "battery-percentage-bar"},
3538
}));
3639
}
3740
}
@@ -138,7 +141,8 @@ void ffPrintGamepadHelpFormat(void)
138141
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_GAMEPAD_MODULE_NAME, "{1} ({3})", FF_GAMEPAD_NUM_FORMAT_ARGS, ((const char* []) {
139142
"Name - name",
140143
"Serial number - serial",
141-
"Battery percentage - battery-percentage",
144+
"Battery percentage num - battery-percentage",
145+
"Battery percentage bar - battery-percentage-bar",
142146
}));
143147
}
144148

src/modules/memory/memory.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "modules/memory/memory.h"
77
#include "util/stringUtils.h"
88

9-
#define FF_MEMORY_NUM_FORMAT_ARGS 3
9+
#define FF_MEMORY_NUM_FORMAT_ARGS 4
1010

1111
void ffPrintMemory(FFMemoryOptions* options)
1212
{
@@ -56,12 +56,15 @@ void ffPrintMemory(FFMemoryOptions* options)
5656
}
5757
else
5858
{
59-
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
60-
ffPercentAppendNum(&percentageStr, percentage, options->percent, false, &options->moduleArgs);
59+
FF_STRBUF_AUTO_DESTROY percentageNum = ffStrbufCreate();
60+
ffPercentAppendNum(&percentageNum, percentage, options->percent, false, &options->moduleArgs);
61+
FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate();
62+
ffPercentAppendBar(&percentageBar, percentage, options->percent, &options->moduleArgs);
6163
FF_PRINT_FORMAT_CHECKED(FF_MEMORY_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_MEMORY_NUM_FORMAT_ARGS, ((FFformatarg[]){
6264
{FF_FORMAT_ARG_TYPE_STRBUF, &usedPretty, "used"},
6365
{FF_FORMAT_ARG_TYPE_STRBUF, &totalPretty, "total"},
64-
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr, "percentage"},
66+
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageNum, "percentage"},
67+
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageBar, "percentage-bar"},
6568
}));
6669
}
6770
}
@@ -130,7 +133,8 @@ void ffPrintMemoryHelpFormat(void)
130133
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_MEMORY_MODULE_NAME, "{1} / {2} ({3})", FF_MEMORY_NUM_FORMAT_ARGS, ((const char* []) {
131134
"Used size - used",
132135
"Total size - total",
133-
"Percentage used - percentage",
136+
"Percentage used (num) - percentage",
137+
"Percentage used (bar) - percentage-bar",
134138
}));
135139
}
136140

src/modules/sound/sound.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "modules/sound/sound.h"
66
#include "util/stringUtils.h"
77

8-
#define FF_SOUND_NUM_FORMAT_ARGS 4
8+
#define FF_SOUND_NUM_FORMAT_ARGS 5
99

1010
static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, uint8_t index)
1111
{
@@ -46,14 +46,17 @@ static void printDevice(FFSoundOptions* options, const FFSoundDevice* device, ui
4646
}
4747
else
4848
{
49-
FF_STRBUF_AUTO_DESTROY percentageStr = ffStrbufCreate();
50-
ffPercentAppendNum(&percentageStr, device->volume, options->percent, false, &options->moduleArgs);
49+
FF_STRBUF_AUTO_DESTROY percentageNum = ffStrbufCreate();
50+
ffPercentAppendNum(&percentageNum, device->volume, options->percent, false, &options->moduleArgs);
51+
FF_STRBUF_AUTO_DESTROY percentageBar = ffStrbufCreate();
52+
ffPercentAppendBar(&percentageBar, device->volume, options->percent, &options->moduleArgs);
5153

5254
FF_PRINT_FORMAT_CHECKED(FF_SOUND_MODULE_NAME, index, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, FF_SOUND_NUM_FORMAT_ARGS, ((FFformatarg[]) {
5355
{FF_FORMAT_ARG_TYPE_BOOL, &device->main, "is-main"},
5456
{FF_FORMAT_ARG_TYPE_STRBUF, &device->name, "name"},
55-
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageStr, "volume-percentage"},
57+
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageNum, "volume-percentage"},
5658
{FF_FORMAT_ARG_TYPE_STRBUF, &device->identifier, "identifier"},
59+
{FF_FORMAT_ARG_TYPE_STRBUF, &percentageBar, "volume-percentage-bar"},
5760
}));
5861
}
5962
}
@@ -228,8 +231,9 @@ void ffPrintSoundHelpFormat(void)
228231
FF_PRINT_MODULE_FORMAT_HELP_CHECKED(FF_SOUND_MODULE_NAME, "{2} ({3}%)", FF_SOUND_NUM_FORMAT_ARGS, ((const char* []) {
229232
"Is main sound device - is-main",
230233
"Device name - name",
231-
"Volume (in percentage) - volume-percentage",
234+
"Volume (in percentage num) - volume-percentage",
232235
"Identifier - identifier",
236+
"Volume (in percentage bar) - volume-percentage-bar",
233237
}));
234238
}
235239

0 commit comments

Comments
 (0)