if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "status")) {
+ } else if (BEGINS_WITH(walk + 1, "status")) {
const char *statusstr;
switch (batt_info.status) {
case CS_CHARGING:
outwalk += sprintf(outwalk, "%s", statusstr);
walk += strlen("status");
+
} else if (BEGINS_WITH(walk + 1, "percentage")) {
if (integer_battery_capacity) {
outwalk += sprintf(outwalk, "%.00f%s", batt_info.percentage_remaining, pct_mark);
outwalk += sprintf(outwalk, "%.02f%s", batt_info.percentage_remaining, pct_mark);
}
walk += strlen("percentage");
+
} else if (BEGINS_WITH(walk + 1, "remaining")) {
if (batt_info.seconds_remaining >= 0) {
int seconds, hours, minutes;
}
walk += strlen("remaining");
EAT_SPACE_FROM_OUTPUT_IF_NO_OUTPUT();
+
} else if (BEGINS_WITH(walk + 1, "emptytime")) {
if (batt_info.seconds_remaining >= 0) {
time_t empty_time = time(NULL) + batt_info.seconds_remaining;
}
walk += strlen("emptytime");
EAT_SPACE_FROM_OUTPUT_IF_NO_OUTPUT();
+
} else if (BEGINS_WITH(walk + 1, "consumption")) {
if (batt_info.present_rate >= 0)
outwalk += sprintf(outwalk, "%1.2fW", batt_info.present_rate / 1e6);
walk += strlen("consumption");
EAT_SPACE_FROM_OUTPUT_IF_NO_OUTPUT();
+
+ } else {
+ *(outwalk++) = '%';
}
}
for (walk = selected_format; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "degrees")) {
+
+ } else if (BEGINS_WITH(walk + 1, "degrees")) {
outwalk += sprintf(outwalk, "%s", temperature.formatted_value);
walk += strlen("degrees");
+
+ } else {
+ *(outwalk++) = '%';
}
}
for (walk = selected_format; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "usage")) {
+ } else if (BEGINS_WITH(walk + 1, "usage")) {
outwalk += sprintf(outwalk, "%02d%s", diff_usage, pct_mark);
walk += strlen("usage");
}
#if defined(LINUX)
- if (BEGINS_WITH(walk + 1, "cpu")) {
+ else if (BEGINS_WITH(walk + 1, "cpu")) {
int number = 0;
sscanf(walk + 1, "cpu%d", &number);
if (number < 0 || number >= cpu_count) {
walk += strlen("cpu") + padding;
}
#endif
+ else {
+ *(outwalk++) = '%';
+ }
}
for (int i = 0; i < cpu_count; i++)
for (walk = selected_format; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "free")) {
+ } else if (BEGINS_WITH(walk + 1, "free")) {
outwalk += print_bytes_human(outwalk, (uint64_t)buf.f_bsize * (uint64_t)buf.f_bfree, prefix_type);
walk += strlen("free");
- }
- if (BEGINS_WITH(walk + 1, "used")) {
+ } else if (BEGINS_WITH(walk + 1, "used")) {
outwalk += print_bytes_human(outwalk, (uint64_t)buf.f_bsize * ((uint64_t)buf.f_blocks - (uint64_t)buf.f_bfree), prefix_type);
walk += strlen("used");
- }
- if (BEGINS_WITH(walk + 1, "total")) {
+ } else if (BEGINS_WITH(walk + 1, "total")) {
outwalk += print_bytes_human(outwalk, (uint64_t)buf.f_bsize * (uint64_t)buf.f_blocks, prefix_type);
walk += strlen("total");
- }
- if (BEGINS_WITH(walk + 1, "avail")) {
+ } else if (BEGINS_WITH(walk + 1, "avail")) {
outwalk += print_bytes_human(outwalk, (uint64_t)buf.f_bsize * (uint64_t)buf.f_bavail, prefix_type);
walk += strlen("avail");
- }
- if (BEGINS_WITH(walk + 1, "percentage_free")) {
+ } else if (BEGINS_WITH(walk + 1, "percentage_free")) {
outwalk += sprintf(outwalk, "%.01f%s", 100.0 * (double)buf.f_bfree / (double)buf.f_blocks, pct_mark);
walk += strlen("percentage_free");
- }
- if (BEGINS_WITH(walk + 1, "percentage_used_of_avail")) {
+ } else if (BEGINS_WITH(walk + 1, "percentage_used_of_avail")) {
outwalk += sprintf(outwalk, "%.01f%s", 100.0 * (double)(buf.f_blocks - buf.f_bavail) / (double)buf.f_blocks, pct_mark);
walk += strlen("percentage_used_of_avail");
- }
- if (BEGINS_WITH(walk + 1, "percentage_used")) {
+ } else if (BEGINS_WITH(walk + 1, "percentage_used")) {
outwalk += sprintf(outwalk, "%.01f%s", 100.0 * (double)(buf.f_blocks - buf.f_bfree) / (double)buf.f_blocks, pct_mark);
walk += strlen("percentage_used");
- }
- if (BEGINS_WITH(walk + 1, "percentage_avail")) {
+ } else if (BEGINS_WITH(walk + 1, "percentage_avail")) {
outwalk += sprintf(outwalk, "%.01f%s", 100.0 * (double)buf.f_bavail / (double)buf.f_blocks, pct_mark);
walk += strlen("percentage_avail");
+
+ } else {
+ *(outwalk++) = '%';
}
}
for (walk = format_up; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "ip")) {
+ } else if (BEGINS_WITH(walk + 1, "ip")) {
outwalk += sprintf(outwalk, "%s", ip_address);
walk += strlen("ip");
+
} else if (BEGINS_WITH(walk + 1, "speed")) {
outwalk += print_eth_speed(outwalk, interface);
walk += strlen("speed");
+
+ } else {
+ *(outwalk++) = '%';
}
}
for (walk = format_up; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "ip")) {
+ } else if (BEGINS_WITH(walk + 1, "ip")) {
outwalk += sprintf(outwalk, "%s", addr_string);
walk += strlen("ip");
+
+ } else {
+ *(outwalk++) = '%';
}
}
END_COLOR;
for (walk = selected_format; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "1min")) {
+
+ } else if (BEGINS_WITH(walk + 1, "1min")) {
outwalk += sprintf(outwalk, "%1.2f", loadavg[0]);
walk += strlen("1min");
- }
- if (BEGINS_WITH(walk + 1, "5min")) {
+ } else if (BEGINS_WITH(walk + 1, "5min")) {
outwalk += sprintf(outwalk, "%1.2f", loadavg[1]);
walk += strlen("5min");
- }
- if (BEGINS_WITH(walk + 1, "15min")) {
+ } else if (BEGINS_WITH(walk + 1, "15min")) {
outwalk += sprintf(outwalk, "%1.2f", loadavg[2]);
walk += strlen("15min");
+
+ } else {
+ *(outwalk++) = '%';
}
}
for (walk = selected_format; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "total")) {
+
+ } else if (BEGINS_WITH(walk + 1, "total")) {
outwalk += print_bytes_human(outwalk, ram_total);
walk += strlen("total");
- }
- if (BEGINS_WITH(walk + 1, "used")) {
+ } else if (BEGINS_WITH(walk + 1, "used")) {
outwalk += print_bytes_human(outwalk, ram_used);
walk += strlen("used");
- }
- if (BEGINS_WITH(walk + 1, "free")) {
+ } else if (BEGINS_WITH(walk + 1, "free")) {
outwalk += print_bytes_human(outwalk, ram_free);
walk += strlen("free");
- }
- if (BEGINS_WITH(walk + 1, "available")) {
+ } else if (BEGINS_WITH(walk + 1, "available")) {
outwalk += print_bytes_human(outwalk, ram_available);
walk += strlen("available");
- }
- if (BEGINS_WITH(walk + 1, "shared")) {
+ } else if (BEGINS_WITH(walk + 1, "shared")) {
outwalk += print_bytes_human(outwalk, ram_shared);
walk += strlen("shared");
- }
- if (BEGINS_WITH(walk + 1, "percentage_free")) {
+ } else if (BEGINS_WITH(walk + 1, "percentage_free")) {
outwalk += sprintf(outwalk, "%.01f%s", 100.0 * ram_free / ram_total, pct_mark);
walk += strlen("percentage_free");
- }
- if (BEGINS_WITH(walk + 1, "percentage_available")) {
+ } else if (BEGINS_WITH(walk + 1, "percentage_available")) {
outwalk += sprintf(outwalk, "%.01f%s", 100.0 * ram_available / ram_total, pct_mark);
walk += strlen("percentage_available");
- }
- if (BEGINS_WITH(walk + 1, "percentage_used")) {
+ } else if (BEGINS_WITH(walk + 1, "percentage_used")) {
outwalk += sprintf(outwalk, "%.01f%s", 100.0 * ram_used / ram_total, pct_mark);
walk += strlen("percentage_used");
- }
- if (BEGINS_WITH(walk + 1, "percentage_shared")) {
+ } else if (BEGINS_WITH(walk + 1, "percentage_shared")) {
outwalk += sprintf(outwalk, "%.01f%s", 100.0 * ram_shared / ram_total, pct_mark);
walk += strlen("percentage_shared");
+
+ } else {
+ *(outwalk++) = '%';
}
}
for (; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "title")) {
+ } else if (BEGINS_WITH(walk + 1, "title")) {
outwalk += sprintf(outwalk, "%s", title);
walk += strlen("title");
+
} else if (BEGINS_WITH(walk + 1, "status")) {
outwalk += sprintf(outwalk, "%s", (exists ? "yes" : "no"));
walk += strlen("status");
+
+ } else {
+ *(outwalk++) = '%';
}
}
for (; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "title")) {
+ } else if (BEGINS_WITH(walk + 1, "title")) {
outwalk += sprintf(outwalk, "%s", title);
walk += strlen("title");
+
} else if (BEGINS_WITH(walk + 1, "status")) {
outwalk += sprintf(outwalk, "%s", (running ? "yes" : "no"));
walk += strlen("status");
+
+ } else {
+ *(outwalk++) = '%';
}
}
for (walk = format; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "time")) {
+ } else if (BEGINS_WITH(walk + 1, "time")) {
strftime(timebuf, sizeof(timebuf), format_time, &tm);
maybe_escape_markup(timebuf, &outwalk);
walk += strlen("time");
+
+ } else {
+ *(outwalk++) = '%';
}
}
}
for (; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "%")) {
+
+ } else if (BEGINS_WITH(walk + 1, "%")) {
outwalk += sprintf(outwalk, "%s", pct_mark);
walk += strlen("%");
- }
- if (BEGINS_WITH(walk + 1, "volume")) {
+
+ } else if (BEGINS_WITH(walk + 1, "volume")) {
outwalk += sprintf(outwalk, "%d%s", ivolume, pct_mark);
walk += strlen("volume");
+
+ } else {
+ *(outwalk++) = '%';
}
}
return outwalk;
for (; *walk != '\0'; walk++) {
if (*walk != '%') {
*(outwalk++) = *walk;
- continue;
- }
- if (BEGINS_WITH(walk + 1, "quality")) {
+ } else if (BEGINS_WITH(walk + 1, "quality")) {
if (info.flags & WIRELESS_INFO_FLAG_HAS_QUALITY) {
if (info.quality_max)
outwalk += sprintf(outwalk, format_quality, PERCENT_VALUE(info.quality, info.quality_max), pct_mark);
*(outwalk++) = '?';
}
walk += strlen("quality");
- }
- if (BEGINS_WITH(walk + 1, "signal")) {
+ } else if (BEGINS_WITH(walk + 1, "signal")) {
if (info.flags & WIRELESS_INFO_FLAG_HAS_SIGNAL) {
if (info.signal_level_max)
outwalk += sprintf(outwalk, "%3d%s", PERCENT_VALUE(info.signal_level, info.signal_level_max), pct_mark);
*(outwalk++) = '?';
}
walk += strlen("signal");
- }
- if (BEGINS_WITH(walk + 1, "noise")) {
+ } else if (BEGINS_WITH(walk + 1, "noise")) {
if (info.flags & WIRELESS_INFO_FLAG_HAS_NOISE) {
if (info.noise_level_max)
outwalk += sprintf(outwalk, "%3d%s", PERCENT_VALUE(info.noise_level, info.noise_level_max), pct_mark);
*(outwalk++) = '?';
}
walk += strlen("noise");
- }
- if (BEGINS_WITH(walk + 1, "essid")) {
+ } else if (BEGINS_WITH(walk + 1, "essid")) {
#ifdef IW_ESSID_MAX_SIZE
if (info.flags & WIRELESS_INFO_FLAG_HAS_ESSID)
maybe_escape_markup(info.essid, &outwalk);
#endif
*(outwalk++) = '?';
walk += strlen("essid");
- }
- if (BEGINS_WITH(walk + 1, "frequency")) {
+ } else if (BEGINS_WITH(walk + 1, "frequency")) {
if (info.flags & WIRELESS_INFO_FLAG_HAS_FREQUENCY)
outwalk += sprintf(outwalk, "%1.1f GHz", info.frequency / 1e9);
else
*(outwalk++) = '?';
walk += strlen("frequency");
- }
- if (BEGINS_WITH(walk + 1, "ip")) {
+ } else if (BEGINS_WITH(walk + 1, "ip")) {
outwalk += sprintf(outwalk, "%s", ip_address);
walk += strlen("ip");
}
-
#ifdef LINUX
- if (BEGINS_WITH(walk + 1, "bitrate")) {
+ else if (BEGINS_WITH(walk + 1, "bitrate")) {
char br_buffer[128];
print_bitrate(br_buffer, sizeof(br_buffer), info.bitrate);
walk += strlen("bitrate");
}
#endif
+ else {
+ *(outwalk++) = '%';
+ }
}
out: