1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 02:25:09 +00:00

add units_spacer option for tuning string between values and units

This commit is contained in:
Marius Feraru 2020-10-09 17:58:31 +03:00 committed by Brenden Matthews
parent 527076d4df
commit 5a674449b4
2 changed files with 19 additions and 6 deletions

View File

@ -1038,6 +1038,15 @@
Zero makes Conky run forever. Zero makes Conky run forever.
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>
<command>
<option>units_spacer</option>
</command>
</term>
<listitem>String to place between values and units. (default: empty)
<para /></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term> <term>
<command> <command>

View File

@ -189,6 +189,8 @@ static conky::simple_config_setting<bool> short_units("short_units", false,
true); true);
static conky::simple_config_setting<bool> format_human_readable( static conky::simple_config_setting<bool> format_human_readable(
"format_human_readable", true, true); "format_human_readable", true, true);
conky::simple_config_setting<std::string> units_spacer("units_spacer", "",
false);
conky::simple_config_setting<bool> out_to_stdout("out_to_console", conky::simple_config_setting<bool> out_to_stdout("out_to_console",
// Default value is false, unless we are building without X // Default value is false, unless we are building without X
@ -613,16 +615,17 @@ void human_readable(long long num, char *buf, int size) {
return; return;
} }
if (short_units.get(*state)) { if (short_units.get(*state)) {
width = 6; width = 5;
format = "%.*f %.1s"; format = "%.*f%s%.1s";
} else { } else {
width = 8; width = 7;
format = "%.*f %-.3s"; format = "%.*f%s%-.3s";
} }
width += strlen(units_spacer.get(*state).c_str());
if (llabs(num) < 1000LL) { if (llabs(num) < 1000LL) {
spaced_print(buf, size, format, width, 0, static_cast<float>(num), spaced_print(buf, size, format, width, 0, static_cast<float>(num),
_(*suffix)); units_spacer.get(*state).c_str(), _(*suffix));
return; return;
} }
@ -655,7 +658,8 @@ void human_readable(long long num, char *buf, int size) {
if (fnum < 99.95) { precision = 1; /* print 10-99 with one decimal place */ } if (fnum < 99.95) { precision = 1; /* print 10-99 with one decimal place */ }
if (fnum < 9.995) { precision = 2; /* print 0-9 with two decimal places */ } if (fnum < 9.995) { precision = 2; /* print 0-9 with two decimal places */ }
spaced_print(buf, size, format, width, precision, fnum, _(*suffix)); spaced_print(buf, size, format, width, precision, fnum,
units_spacer.get(*state).c_str(), _(*suffix));
} }
/* global object list root element */ /* global object list root element */