Commit 5a8f93f3175844e605bb8475c0d594d67fedf242
1 parent
9db77de9ed
Exists in
master
sanitized?
Showing 2 changed files with 9 additions and 8 deletions Side-by-side Diff
README
View file @
5a8f93f
status.c
View file @
5a8f93f
1 | 1 | /* made by profil 2011-12-29. |
2 | 2 | * Added: |
3 | 3 | * * Battery and temperature status for Linux and FreeBSD |
4 | - * | |
5 | - * Compile with: | |
6 | - * bestcc -Wnone -pedantic -std=c49 -lX11 status.c -o status | |
7 | 4 | */ |
8 | 5 | #include <stdio.h> |
9 | 6 | #include <stdlib.h> |
... | ... | @@ -135,7 +132,7 @@ |
135 | 132 | return "?"; |
136 | 133 | } |
137 | 134 | |
138 | - snprintf(buf, 16, "BAT %d", batval); | |
135 | + snprintf(buf, BATBUF_LEN, "BAT %d", batval); | |
139 | 136 | |
140 | 137 | fclose(batstat); |
141 | 138 | |
142 | 139 | |
... | ... | @@ -154,9 +151,9 @@ |
154 | 151 | plugged_in_err = sysctl(power, 3, &plugged_in, &batlife_len, NULL, 0); |
155 | 152 | |
156 | 153 | if (plugged_in_err || !plugged_in) { |
157 | - snprintf(buf, 16, "BAT %d", batlife); | |
154 | + snprintf(buf, BATBUF_LEN, "BAT %d", batlife); | |
158 | 155 | } else { |
159 | - snprintf(buf, 16, "AC, BAT %d", batlife); | |
156 | + snprintf(buf, BATBUF_LEN, "AC, BAT %d", batlife); | |
160 | 157 | } |
161 | 158 | |
162 | 159 | #endif |
... | ... | @@ -170,7 +167,10 @@ |
170 | 167 | mib_temp[TEMP_MIB_LEN], |
171 | 168 | mib_ac[AC_MIB_LEN]; |
172 | 169 | |
173 | - char bat_buf[8], datetime_buf[65], temp_buf[8], status[200]; | |
170 | + char bat_buf[BATBUF_LEN], | |
171 | + datetime_buf[DATETIME_LEN], | |
172 | + temp_buf[TEMPER_LEN], | |
173 | + status[STATUS_LEN]; | |
174 | 174 | |
175 | 175 | if (!(dpy = XOpenDisplay(NULL))) { |
176 | 176 | fprintf(stderr, "Cannot open display.\n"); |
... | ... | @@ -189,7 +189,6 @@ |
189 | 189 | snprintf(status, 200, "%s%% | %s | %s", |
190 | 190 | getbat(mib_bat, mib_ac), gettemp(mib_temp), datetime); |
191 | 191 | |
192 | - | |
193 | 192 | setstatus(status); |
194 | 193 | } |
195 | 194 |