Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom battery %emptytime string when battery is full #479

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions i3status.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ int main(int argc, char *argv[]) {
CFG_BOOL("last_full_capacity", false, CFGF_NONE),
CFG_BOOL("integer_battery_capacity", false, CFGF_NONE),
CFG_BOOL("hide_seconds", true, CFGF_NONE),
CFG_STR("battery_full_emptytime", "", CFGF_NONE),
CFG_CUSTOM_ALIGN_OPT,
CFG_CUSTOM_COLOR_OPTS,
CFG_CUSTOM_MIN_WIDTH_OPT,
Expand Down Expand Up @@ -747,6 +748,7 @@ int main(int argc, char *argv[]) {
.last_full_capacity = cfg_getbool(sec, "last_full_capacity"),
.format_percentage = cfg_getstr(sec, "format_percentage"),
.hide_seconds = cfg_getbool(sec, "hide_seconds"),
.battery_full_emptytime = cfg_getstr(sec, "battery_full_emptytime"),
};
print_battery_info(&ctx);
SEC_CLOSE_MAP;
Expand Down
1 change: 1 addition & 0 deletions include/i3status.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ typedef struct {
bool last_full_capacity;
const char *format_percentage;
bool hide_seconds;
const char *battery_full_emptytime;
} battery_info_ctx_t;

void print_battery_info(battery_info_ctx_t *ctx);
Expand Down
3 changes: 3 additions & 0 deletions src/print_battery_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ void print_battery_info(battery_info_ctx_t *ctx) {
snprintf(string_emptytime, STRING_SIZE, "%02d:%02d:%02d", max(empty_tm->tm_hour, 0), max(empty_tm->tm_min, 0), max(empty_tm->tm_sec, 0));
}

if (batt_info.seconds_remaining < 0 && ctx->battery_full_emptytime[0] != 0)
snprintf(string_emptytime, STRING_SIZE, "%s", ctx->battery_full_emptytime);

if (batt_info.present_rate >= 0)
snprintf(string_consumption, STRING_SIZE, "%1.2fW", batt_info.present_rate / 1e6);

Expand Down