Battery + System Stats widgets development thread

A way to get current battery percentage: pmset -g batt | grep -m 1 - | cut -d ' ' -f 3 | cut -d$'\t' -f 2 | sed 's/.$//'

1 Like

Does anyone know how to get CPU usage percent (out of 100%), total memory, and available memory? I'm having a hard time finding a preexisting top command for these outputs.

EDIT: Making progress by learning how to use grep lol

CPU (due to multicore not quite straight forward):
ncpu=$(sysctl -n hw.logicalcpu)
total=$(ps -Ao %cpu= | paste -sd+ - | bc)
usage=$(echo "scale = 2; $total / $ncpu" | bc)
printf "%0.1f%%\n" "$usage"

Total Memory: sysctl hw.memsize
Used: top -l 1 -s 0 | grep PhysMem

1 Like

Got things looking not totally broken!

Cleaned up a bit more!

The battery information could also be retrieved using Objective-C methods.

@GoldenChaos - could you make it so that clicking the memory button will clean the memory? Just like 3rd party apps can?

I don't think those "free up memory" tools are doing something I can invoke with a simple terminal command - but I can look into it!

Thanks for responding! I appreciate it!

Free up memory tools just fill up the memory until the system cleans it. There is no use in them (just placebo). The system will automatically free up memory if necessary.


ahhh... thanks for informing me!

Also, @Andreas_Hegenburg, could you check my bug report? Sadly no one has actually responded to my bug report :frowning:

To add to the responses above. The following available in the link below:

  • Battery Percent Left
  • Battery Time Left
  • Battery Temperature
  • CPU Percentage
  • Memory Free/Inactive/Active/etc.
  • Network Download & Upload Throughput
1 Like

Good find. I added battery temperature information to thread I linked in here earlier.

It's coming along! Icons are just placeholder while I figure out the optimal layout...

That's weird. Are you getting the negative download throughput naturally?

Yep. Was wondering about that...

Hi ! Thank you for your great work!

  1. I unchecked "Show Percentage" and "Remaining Time" But it still shows remaining time.

is there any way to fix ?
I just bought this app yesterday !

1 Like

That option only affects the menu bar widget - the long-press stats group doesn't have any configurable settings!

Hi everyone,

does anyone know if it's possible to have the battery icon on top and the time remaining underneath? Somethine like this:
Touch Bar Shot 2020-05-29 at 12.30.21

Imprint | Privacy Policy