mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-09-29 05:29:11 +00:00
add units_spacer option for tuning string between values and units
This commit is contained in:
parent
527076d4df
commit
5a674449b4
@ -1038,6 +1038,15 @@
|
||||
Zero makes Conky run forever.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>units_spacer</option>
|
||||
</command>
|
||||
</term>
|
||||
<listitem>String to place between values and units. (default: empty)
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
|
16
src/conky.cc
16
src/conky.cc
@ -189,6 +189,8 @@ static conky::simple_config_setting<bool> short_units("short_units", false,
|
||||
true);
|
||||
static conky::simple_config_setting<bool> format_human_readable(
|
||||
"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",
|
||||
// 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;
|
||||
}
|
||||
if (short_units.get(*state)) {
|
||||
width = 6;
|
||||
format = "%.*f %.1s";
|
||||
width = 5;
|
||||
format = "%.*f%s%.1s";
|
||||
} else {
|
||||
width = 8;
|
||||
format = "%.*f %-.3s";
|
||||
width = 7;
|
||||
format = "%.*f%s%-.3s";
|
||||
}
|
||||
width += strlen(units_spacer.get(*state).c_str());
|
||||
|
||||
if (llabs(num) < 1000LL) {
|
||||
spaced_print(buf, size, format, width, 0, static_cast<float>(num),
|
||||
_(*suffix));
|
||||
units_spacer.get(*state).c_str(), _(*suffix));
|
||||
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 < 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 */
|
||||
|
Loading…
Reference in New Issue
Block a user