diff --git a/dwm-stat/Makefile b/dwm-stat/Makefile index 579b7bd..c6e0efe 100644 --- a/dwm-stat/Makefile +++ b/dwm-stat/Makefile @@ -7,6 +7,9 @@ laptop: # compiling with LAPTOP=1 gcc -D LAPTOP=1 status.c -o $(output) $(flags) +run: + ./statline + clean: rm -f statline diff --git a/dwm-stat/status.c b/dwm-stat/status.c index 2f86f58..1955384 100644 --- a/dwm-stat/status.c +++ b/dwm-stat/status.c @@ -17,6 +17,7 @@ #define BASIC_MSG "/comfy/ o clock | " #define TIME_FORMAT "%I:%M%p - %d %b %Y" +// Time in seconds #define TIME_DELAY 5 #define MAXSTR 1024 @@ -62,6 +63,7 @@ ram_usage(void) #ifdef LAPTOP #define BATTERY_STATUS_BUFFER 50 +#define REDUCER 1000 static char* battery_percentage(void) { @@ -72,17 +74,18 @@ battery_percentage(void) if(file_max) { fgets(buf, BATTERY_STATUS_BUFFER, file_max); fclose(file_max); - total = atoi(buf); + total = atoi(buf)/REDUCER; } FILE* file_curr = fopen("/sys/class/power_supply/BAT0/energy_now", "r"); if(file_curr) { fgets(buf, BATTERY_STATUS_BUFFER, file_max); fclose(file_curr); - total = atoi(buf); + curr = atoi(buf)/REDUCER; } - snprintf(buf, BATTERY_STATUS_BUFFER, "Battery: %.2f", (float)(curr/total)); + float level = (float)curr / (float)total; + snprintf(buf, BATTERY_STATUS_BUFFER, "Battery: %.2f%%", level*100); return buf; } #endif