Skip to content

Commit

Permalink
Add battery charge to tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
walles committed Oct 19, 2020
1 parent ca9178c commit 2309b09
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/bubblemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ static void usage2string(char *string,

const char *bubblemon_getTooltip(bubblemon_t *bubblemon)
{
char memstring[20], swapstring[20], iowaitstring[40], loadstring[50];
char memstring[20], swapstring[20], iowaitstring[40], loadstring[50], batterystring[50];
int cpu_number;

if (!bubblemon->tooltipstring)
{
/* Prevent the tooltipstring buffer from overflowing on a system
with lots of CPUs */
bubblemon->tooltipstring =
malloc(sizeof(char) * (bubblemon->sysload.nCpus * 50 + 200));
malloc(sizeof(char) * (bubblemon->sysload.nCpus * 50 + 500));
assert(bubblemon->tooltipstring != NULL);
}

Expand All @@ -204,6 +204,11 @@ const char *bubblemon_getTooltip(bubblemon_t *bubblemon)
bubblemon->sysload.ioLoad);
strcat(bubblemon->tooltipstring, iowaitstring);

snprintf(batterystring, 49,
_("\nBattery charge: %d%%"),
bubblemon->sysload.batteryChargePercent);
strcat(bubblemon->tooltipstring, batterystring);

if (bubblemon->sysload.nCpus == 1)
{
snprintf(loadstring, 45,
Expand Down

0 comments on commit 2309b09

Please sign in to comment.