Skip to content
This repository has been archived by the owner on Jan 5, 2018. It is now read-only.

Commit

Permalink
read only first char of BAT_STATE
Browse files Browse the repository at this point in the history
  • Loading branch information
Theta91 committed Sep 4, 2014
1 parent 4913757 commit d680503
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dwmst.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,19 @@ get_vol(snd_mixer_t *handle, snd_mixer_elem_t *elem) {
char *
get_bat(void) {
FILE *f;
char state[11];
char state;
float now, full, voltage, rate;
int perc, minutes, hours;

if(access("/sys/class/power_supply/BAT1/", F_OK) != 0)
return NO_BAT;

f = fopen(BAT_STATE, "r"); if(f == NULL) return BAT_UNK;
fscanf(f, "%s", state); fclose(f);
state = (char)fgetc(f); fclose(f);

if(state[0] == 'F')
if(state == 'F')
return BAT_FULL;
if(state[0] == 'U')
if(state == 'U')
return BAT_UNK;

f = fopen(BAT_FULLL, "r"); if(f == NULL) return BAT_UNK;
Expand All @@ -181,7 +181,7 @@ get_bat(void) {
rate *= voltage;
perc = (now * 100) / full;

if(state[0] == 'C') {
if(state == 'C') {
minutes = 60 * ((full - now) / rate);
hours = minutes / 60;
minutes -= 60 * hours;
Expand Down

0 comments on commit d680503

Please sign in to comment.