diff options
author | Daniel Jones <admin@danieljon.es> | 2019-12-11 23:59:00 +1030 |
---|---|---|
committer | Daniel Jones <admin@danieljon.es> | 2019-12-11 23:59:00 +1030 |
commit | 7ed46f531ccf25db7edb980cfb0910d6a63f38b9 (patch) | |
tree | 00f0800ddac799e80561205275e8e12868c7cff1 /components.c | |
parent | 97a0e09ae4a68ea85db3b9abc65df8de7b230439 (diff) | |
download | binstatus-7ed46f531ccf25db7edb980cfb0910d6a63f38b9.tar.gz binstatus-7ed46f531ccf25db7edb980cfb0910d6a63f38b9.zip |
added support for military, binary and 12 hour time
also changed the text displayed for battery states as they were far too long
my thinkpad claims the batteyr status is "unknown" when fully charged, so we interpret that as meaning fully charged...
Diffstat (limited to 'components.c')
-rw-r--r-- | components.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/components.c b/components.c index a8a27db..09c1fc0 100644 --- a/components.c +++ b/components.c @@ -14,6 +14,8 @@ */ #include "components.h" +#include "config.h" + int dectobin(int dec) { @@ -51,8 +53,22 @@ char *currenttime(char *store, size_t size, int flag) { int time[2]; gettime(time); - snprintf(store, size, "%02d:%02d ", time[0], time[1]); - return store; + if (flag & NORMALTIME) + { + if (time[0] > 12) + time[0] = converthour(time[0]); + } + if (flag & BINARYTIME) + { + snprintf(store, size, "%05d:%05d ", dectobin(time[0]), + dectobin(time[1])); + } + /* military time is the default, so we need not do anything */ + else + { + snprintf(store, size, "%02d:%02d ", time[0], time[1]); + } + return store; } char *battery(char *store, size_t size, int flag) @@ -83,7 +99,17 @@ char *charging(char *store, size_t size, int flag) } fgets(cap, 15, state); eat(cap, strlen(cap)); + /* my thinkpad says "Unknown" when charged ... */ + if (strcmp(cap, "Unknown") == 0) strcpy(cap, "⚡F"); + if (strcmp(cap, "Charged") == 0) strcpy(cap, "⚡F"); + if (strcmp(cap, "Charging") == 0) strcpy(cap, "⚡C"); + if (strcmp(cap, "Discharging") == 0) strcpy(cap, "⚡D"); fclose(state); snprintf(store, size, "%s ", cap); return store; } + +char *remainingtime(char *store, size_t size, int flag) +{ + return store; +} |