Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu_temperature: support format_down #499

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions i3status.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ int main(int argc, char *argv[]) {
cfg_opt_t temp_opts[] = {
CFG_STR("format", "%degrees C", CFGF_NONE),
CFG_STR("format_above_threshold", NULL, CFGF_NONE),
CFG_STR("format_down", "can't read temp", CFGF_NONE),
CFG_STR("path", NULL, CFGF_NONE),
CFG_INT("max_threshold", 75, CFGF_NONE),
CFG_CUSTOM_ALIGN_OPT,
Expand Down Expand Up @@ -907,6 +908,7 @@ int main(int argc, char *argv[]) {
.path = cfg_getstr(sec, "path"),
.format = cfg_getstr(sec, "format"),
.format_above_threshold = cfg_getstr(sec, "format_above_threshold"),
.format_down = cfg_getstr(sec, "format_down"),
.max_threshold = cfg_getint(sec, "max_threshold"),
};
print_cpu_temperature_info(&ctx);
Expand Down
1 change: 1 addition & 0 deletions include/i3status.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ typedef struct {
const char *path;
const char *format;
const char *format_above_threshold;
const char *format_down;
int max_threshold;
} cpu_temperature_ctx_t;

Expand Down
3 changes: 2 additions & 1 deletion man/i3status.man
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ Gets the temperature of the given thermal zone. It is possible to
define a +max_threshold+ that will color the temperature red in case the
specified thermal zone is getting too hot. Defaults to 75 degrees C. The
output format when above +max_threshold+ can be customized with
+format_above_threshold+.
+format_above_threshold+. There also is an option +format_down+. You can hide
the output with +format_down=""+.

*Example order*: +cpu_temperature 0+

Expand Down
2 changes: 1 addition & 1 deletion src/print_cpu_temperature.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,6 @@ void print_cpu_temperature_info(cpu_temperature_ctx_t *ctx) {
free(thermal_zone);
#endif

OUTPUT_FULL_TEXT("can't read temp");
OUTPUT_FULL_TEXT(ctx->format_down);
(void)fputs("i3status: Cannot read temperature. Verify that you have a thermal zone in /sys/class/thermal or disable the cpu_temperature module in your i3status config.\n", stderr);
}