Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Battery usage support #46

Closed
dylanaraps opened this issue Feb 1, 2016 · 19 comments
Closed

Battery usage support #46

dylanaraps opened this issue Feb 1, 2016 · 19 comments
Assignees

Comments

@dylanaraps
Copy link
Owner

Hi guys,

I'm currently working on adding support for the new battery function to the
other OS we support. I don't own anything with a battery so I'll need some help
testing.

Here's the TODO for the battery function:

  • Add support for all platforms
    • The only OS without support are the BSDs as we have no one to help test.
    • I'll be getting a laptop soon so support will come eventually.
  • Add an option to only print the first battery or X number of batteries.
  • Add an option to print all batteries on a single line.
@dylanaraps
Copy link
Owner Author

OS X users, what do these commands output?

pmset -g batt | grep -o '[0-9]*%' | tr -d %

ioreg -n AppleSmartBattery -r | grep -o '"[^"]*" = [^ ]*' | sed -e 's/= //g' -e 's/"//g' | sort

Windows users, what do these commands output?

WMIC Path Win32_Battery

WMIC PATH Win32_Battery Get EstimatedChargeRemaining

FreeBSD users, what do these commands output?

acpiconf -i 0 | awk '/Remaining capacity:/ {printf $2}'

acpiconf -i * | awk '/Remaining capacity:/ {printf $2}'

I'm still trying to find the commands for OpenBSD and NetBSD.

@dylanaraps dylanaraps self-assigned this Feb 2, 2016
@dylanaraps dylanaraps mentioned this issue Feb 2, 2016
Closed
6 tasks
@ladislavskufca
Copy link

You can tag me next time for OS X test, I will respond to you much faster.
First one is 100.
Second one is :

    1. AdapterInfo 0
    1. Amperage 0
    1. AvgTimeToEmpty 65535
    1. AvgTimeToFull 65535
    1. BatteryInstalled Yes
    1. BatteryInvalidWakeSeconds 30
    1. BatterySerialNumber XXX (don't want to share)
    1. BootPathUpdated 1454405207
    1. CellVoltage (4090,4112,4085,0)
    1. CurrentCapacity 6014
    1. CycleCount 340
    1. DesignCapacity 6330
    1. DesignCycleCount9C 1000
    1. DeviceName bq20z451
    1. ExternalChargeCapable Yes
    1. ExternalConnected Yes
    1. FirmwareSerialNumber 1
    1. FullPathUpdated 1454421662
    1. FullyCharged Yes
    1. IOGeneralInterest IOCommand
    1. InstantAmperage 0
    1. InstantTimeToEmpty 174
    1. IsCharging No
    1. LegacyBatteryInfo {Amperage=0,Flags=5,Capacity=6059,Current=6014,Voltage=12287,Cycle
    1. Location 0
    1. ManufactureDate 17545
    1. ManufacturerData <000000000702000a038900000XXXXXXXXXXXX (don't want to share)>
    1. MaxCapacity 6059
    1. MaxErr 1
    1. OperationStatus 58435
    1. PackReserve 200
    1. PermanentFailureStatus 0
    1. PostChargeWaitSeconds 120
    1. PostDischargeWaitSeconds 120
    1. Temperature 2943
    1. TimeRemaining 0
    1. UserVisiblePathUpdated 1454421842
    1. Voltage 12287

What are you planing to display? I think it would be nice to display current battery status and then options for cycle count, current capacity & design capacity and also fully charged & is charging.

@ladislavskufca
Copy link

Win 10 git bash:
$ WMIC Path Win32_Battery

Availability  BatteryRechargeTime  BatteryStatus  Caption           Chemistry  ConfigManagerErrorCode  ConfigManagerUserConfig  CreationClassNam                                    e  Description       DesignCapacity  DesignVoltage  DeviceID     ErrorCleared  ErrorDescription  EstimatedChargeRemaining  EstimatedRunTime  Exp                                    ectedBatteryLife  ExpectedLife  FullChargeCapacity  InstallDate  LastErrorCode  MaxRechargeTime  Name     PNPDeviceID  PowerManagementCapabiliti                                    es  PowerManagementSupported  SmartBatteryVersion  Status  StatusInfo  SystemCreationClassName  SystemName       TimeOnBattery  TimeToFullCharge                                    
2                                  2              Internal Battery  2                                                           Win32_Battery                                          Internal Battery                  12112          ASUSXXXXX                                  98                        12312121                                                                                                                                                  XXXXX               {1}                                                              FALSE                                          OK                  Win32_ComputerSystem     DESKTOP-XXXXXX                                                                    

$ WMIC PATH Win32_Battery Get EstimatedChargeRemaining
EstimatedChargeRemaining
9

@dylanaraps
Copy link
Owner Author

Thanks for the reply and for testing the commands for me!

Currently the battery function prints in this format:

# Single battery
Battery: XX%

# Multiple
Battery0: XX%
Battery1: XX%

# Shorthand Multiple
Battery: XX%, XX%

For now we'll leave battery support at just usage %, I'm getting a laptop for uni in a few weeks so I'll be able dedicate time to implement is charging, current capacity etc properly.

I'll add support for OS X in the morning, it's 2 am here so I'll be heading off to bed. For the Windows output is the 2nd command's output the percentage? It's weird that it's just 9 as the first command shows it as 98.

@dylanaraps
Copy link
Owner Author

One more thing, what does this output on OS X?

cat /sys/class/power_supply/BAT*/capacity

@ladislavskufca
Copy link

Yeah sry, its 98, just copy/paste things.

Ok great, if I had time I would love to help you, but I have exams those days. Meybe after them if you like.

Nothing, because I can't even cd into /sys like it doesn't exist? The only thing starting on s is sbin.

Sleep well.

@dylanaraps
Copy link
Owner Author

Is it possible for an OS X system to have multiple batteries in use at the same time?

@ladislavskufca
Copy link

Hmm I am 99% sure that this is not possible but I was just thinking about the new Macbook 12 which has multiple layers or batteries, maybe some info will be different?

But I don't think there will this "multibattery problem" on OS X so don't waste your time implementing this imo.

@dylanaraps
Copy link
Owner Author

I've added support for Mac OS X and Windows, please test it out when you can @mclado!

The config options are related to multi-battery and won't work on OS X and Windows for now.
To add support for multi-battery output on Windows I'll need to know the command output so I can,
parse it correctly which means that we'll have to wait for someone with a multi-battery laptop to open
an issue.

@ladislavskufca
Copy link

OS X works like it should, check!

@dylanaraps
Copy link
Owner Author

Awesome!

How about Windows?

@ladislavskufca
Copy link

Nope, something is not ok.

 Disk: 137G / 154G (90%)
 Battery: %

@dylanaraps
Copy link
Owner Author

I just pushed a fix to master, it should work now.

@ladislavskufca
Copy link

Still not working for me. Using git bash instead of cygwin should't be the problem, right?

@dylanaraps
Copy link
Owner Author

It shouldn't be an issue as wmic comes with windows, do these commands work on their own?

wmic Path Win32_Battery get EstimatedChargeRemaining /value
wmic Path Win32_Battery get EstimatedChargeRemaining

@ladislavskufca
Copy link

Oh wait a sec, it is! Just found out because I tried manually. I am getting "Invalid GET Expression" (in git bash). But the command in cygwin works well. I can't get this cygwin to work as it should so I could run full fetch script. Running manually lines 1240 - 1245 gives me $ echo $battery 100 100 %

@dylanaraps
Copy link
Owner Author

I've fixed the doubled usage in my local branch, thanks for finding it.

What about this command in git bash?:

cmd /c wmic Path Win32_Battery get EstimatedChargeRemaining /value

@dylanaraps
Copy link
Owner Author

I just pushed a fix to master for the doubled battery usage.

@dylanaraps
Copy link
Owner Author

If the command above doesn't work in git bash then I'm going to close this issue as it works in CYGWIN.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants