diff --git a/README b/README new file mode 100644 index 0000000..cbfd481 --- /dev/null +++ b/README @@ -0,0 +1,2 @@ +Statusbar setter for DWM that should work in FreeBSD and Linux. +Displays battery status, temperature, date and time. diff --git a/status.c b/status.c index fe8cde4..ca6992f 100644 --- a/status.c +++ b/status.c @@ -1,9 +1,6 @@ /* made by profil 2011-12-29. * Added: * * Battery and temperature status for Linux and FreeBSD - * - * Compile with: - * bestcc -Wnone -pedantic -std=c49 -lX11 status.c -o status */ #include #include @@ -135,7 +132,7 @@ getbat(int *mib, int *power) return "?"; } - snprintf(buf, 16, "BAT %d", batval); + snprintf(buf, BATBUF_LEN, "BAT %d", batval); fclose(batstat); @@ -154,9 +151,9 @@ getbat(int *mib, int *power) plugged_in_err = sysctl(power, 3, &plugged_in, &batlife_len, NULL, 0); if (plugged_in_err || !plugged_in) { - snprintf(buf, 16, "BAT %d", batlife); + snprintf(buf, BATBUF_LEN, "BAT %d", batlife); } else { - snprintf(buf, 16, "AC, BAT %d", batlife); + snprintf(buf, BATBUF_LEN, "AC, BAT %d", batlife); } #endif @@ -170,7 +167,10 @@ main() mib_temp[TEMP_MIB_LEN], mib_ac[AC_MIB_LEN]; - char bat_buf[8], datetime_buf[65], temp_buf[8], status[200]; + char bat_buf[BATBUF_LEN], + datetime_buf[DATETIME_LEN], + temp_buf[TEMPER_LEN], + status[STATUS_LEN]; if (!(dpy = XOpenDisplay(NULL))) { fprintf(stderr, "Cannot open display.\n"); @@ -189,7 +189,6 @@ main() snprintf(status, 200, "%s%% | %s | %s", getbat(mib_bat, mib_ac), gettemp(mib_temp), datetime); - setstatus(status); }