tbatt.c: show power consumption - spoon - [fork] customized build of spoon, the dwm status utility (HTM) git clone git://src.adamsgaard.dk/spoon (DIR) Log (DIR) Files (DIR) Refs (DIR) LICENSE --- (DIR) commit b351340dc924cffe79aefc12700c2d6f0ea3d7e6 (DIR) parent 7365d31d3c34ce9d6ae191a4e38a9817199cf22c (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Wed, 31 Aug 2022 22:18:33 +0200 batt.c: show power consumption Diffstat: M batt.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- (DIR) diff --git a/batt.c b/batt.c t@@ -10,16 +10,17 @@ char *crit[] = { }; void -battprint(char *buf, size_t len, int acon, int life, int remain) +battprint(char *buf, size_t len, int acon, int life, int remain, int power) { char c; static int frame = 0; c = acon ? '=' : ' '; if (c == ' ' && remain != 0) - snprintf(buf, len, " %d%% %d:%02d |", life, remain/60, remain%60); + snprintf(buf, len, " %d%% %d:%02d (%.2g W) |", + life, remain/60, remain%60, (float)power/1000000); else - snprintf(buf, len, " %d%% |", life); + snprintf(buf, len, " %d%% (%.2g W) |", life, (float)power/1000000); } t@@ -94,7 +95,7 @@ battread(void *arg, char *buf, size_t len) } fscanf(fp, "%d", &power); fclose(fp); - battprint(buf, len, acon, life, (float)energy / power * 60.0); + battprint(buf, len, acon, life, (float)energy / power * 60.0, power); return 0; } #endif