Battery + System Stats widgets development thread

from your last update I presume that Battery stats are high on your list?

Use the following command:

ioreg -w 0 -f -r -c AppleSmartBattery

Result:

+-o AppleSmartBattery  <class AppleSmartBattery, id 0x1000002cd, registered, matched, active, busy 0 (0 ms), retain 6>
    {
      "TimeRemaining" = 138
      "ExternalConnected" = No
      "AvgTimeToEmpty" = 138
      "AppleRawCurrentCapacity" = 5944
      "InstantTimeToEmpty" = 65535
      "AppleRawMaxCapacity" = 6113
      "ExternalChargeCapable" = No
      "FullPathUpdated" = 1564428995
      "CellVoltage" = (4305,4306,4305,0)
      "Voltage" = 12253
      "BatteryInvalidWakeSeconds" = 30
      "AdapterInfo" = 0
      "MaxCapacity" = 6113
      "PermanentFailureStatus" = 0
      "DesignCycleCount70" = 0
      "Manufacturer" = "SMP"
      "AppleRawAdapterDetails" = ()
      "Location" = 0
      "CurrentCapacity" = 5944
      "LegacyBatteryInfo" = {"Amperage"=18446744073709549023,"Flags"=4,"Capacity"=6113,"Current"=5944,"Voltage"=12253,"Cycle Count"=251}
      "BatteryFCCData" = {"ResScale"=200}
      "BatteryInstalled" = Yes
      "FirmwareSerialNumber" = 1
      "CycleCount" = 251
      "PackReserve" = 200
      "DesignCapacity" = 6669
      "OperationStatus" = 58435
      "ManufactureDate" = 19050
      "BestAdapterIndex" = 254
      "AvgTimeToFull" = 65535
      "BatterySerialNumber" = "D867105E2ZBHDWCAN"
      "BootPathUpdated" = 1564177670
      "ChargerData" = {"ChargingVoltage"=13048,"ChargingCurrent"=0,"NotChargingReason"=1}
      "PostDischargeWaitSeconds" = 120
      "Temperature" = 3011
      "BatteryData" = {"StateOfCharge"=98,"PMUConfigured"=0,"Voltage"=12691,"QmaxCell1"=6778,"AdapterPower"=0,"SystemPower"=4425,"ResScale"=200,"QmaxCell2"=6769,"QmaxCell0"=6768,"CycleCount"=251,"DesignCapacity"=6669}
      "UserVisiblePathUpdated" = 1564429355
      "IOReportLegendPublic" = Yes
      "InstantAmperage" = 18446744073709548794
      "FullyCharged" = Yes
      "ManufacturerData" =
        00000000: 00 00 00 00 07 02 00 01 39 25 00 00 03 35 38 30 03 30 30 32 03 41 54 4C 01 3C 00                ........9%...580.002.ATL.<.
      "DeviceName" = "bq20z451"
      "MaxErr" = 1
      "IOGeneralInterest" = "IOCommand is not serializable"
      "IOReportLegend" = ({"IOReportChannels"=((7167869599145487988,6460407809,"BatteryCycleCount")),"IOReportGroupName"="Battery","IOReportChannelInfo"={"IOReportChannelUnit"=0}})
      "Amperage" = 18446744073709549023
      "IsCharging" = No
      "DesignCycleCount9C" = 1000
      "PostChargeWaitSeconds" = 120
      "AdapterDetails" = {"FamilyCode"=0}
    }

I'm not aware of any way to get temperature or fan speed without sudo or a 3rd party tool in terminal, but maybe @Andreas_Hegenberg could add smc-command capabilities and provide the information in some builtin variables?

2 Likes

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.

2 Likes

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!

Imprint | Privacy Policy