Skip to content

Commit

Permalink
Still write battery if no date format specified
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthmrao committed Feb 25, 2024
1 parent ade1241 commit 4fb870a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion render.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static void subtext(struct swaylock_surface *surface, char **tstr, char **dstr,
time_t t = time(NULL);
struct tm *tm = localtime(&t);

// Write time
if (surface->state->args.timestr[0]) {
strftime(tbuf, sizeof(tbuf), surface->state->args.timestr, tm);
*tstr = tbuf;
Expand Down Expand Up @@ -82,8 +83,16 @@ static void subtext(struct swaylock_surface *surface, char **tstr, char **dstr,
strncpy(dbuf, tempbuf, sizeof(dbuf));
// Assign dbuf to *dstr
*dstr = dbuf;
} else if (surface->state->args.battery) {
char tempbuf[256];
// Write battery percentage
snprintf(tempbuf, sizeof(tempbuf), "%s", battery_str);
// Copy the modified date string to dbuf
strncpy(dbuf, tempbuf, sizeof(dbuf));
// Assign dbuf to *dstr
*dstr = dbuf;
} else {
*dstr = NULL;
*dstr = NULL;
}


Expand Down

0 comments on commit 4fb870a

Please sign in to comment.