aboutsummaryrefslogtreecommitdiff
path: root/src/print_battery_info.c
AgeCommit message (Collapse)AuthorFilesLines
2016-08-14Move full_design and full_last into struct battery_info.Tommie Gannert1-44/+34
This is in preparation for moving the ratio computation code out of slurp_battery_info to support aggregating multiple batteries.
2016-08-14Also capture charge rate in NetBSD.Tommie Gannert1-0/+3
For time estimates when charging.
2016-08-14Fix warnings about using a char array index on NetBSD.Tommie Gannert1-8/+8
The isspace macro is just a table lookup.
2016-08-14Simplify string comparisons in slurp_battery_info for NetBSD.Tommie Gannert1-47/+11
Doing strlen(a) == strlen(b) && strncmp(a, b, N) seems to have no benefits compared to just strcmp(a, b). The NetBSD cstring properties come from the kernel, not the user. The test for units did a prefix match, but that looked like a bug, the unit is "Watt hour" in my Virtual box.
2016-08-14Remove warnings about unused variables in slurp_battery_info on OpenBSD.Tommie Gannert1-5/+9
2016-08-03Move OS-specific code to slurp_battery_info.Tommie Gannert1-63/+72
2016-08-03Introduce a struct battery_info to carry information from data retrieval to ↵Tommie Gannert1-50/+59
the output formatter.
2016-08-03Refactor common seconds_remaining code in print_battery_info.Tommie Gannert1-19/+16
2016-08-03Remove an END_COLOR in print_battery_info for OpenBSD.Tommie Gannert1-3/+0
This was probably a bug since it makes no sense to have here.
2016-08-03Move START_COLOR to after OS-specific code.Tommie Gannert1-61/+10
This uses the more direct tests of whether percentage_remaining and seconds_remaining are available or not (rather than looking at present_rate).
2016-08-03Remove consumptionbuf from print_battery_info.Tommie Gannert1-10/+3
2016-08-03Remove emptytimebuf from print_battery_info.Tommie Gannert1-30/+11
This changes the behavior for NetBSD: previously this time was not shown while charging. On Linux it was treated as "full time". This change makes all OSes behave the same. OpenBSD and FreeBSD did not support emptytime previously.
2016-08-03Remove remainingbuf from print_battery_info.Tommie Gannert1-53/+28
2016-08-01Remove percentagebuf from print_battery_info.Tommie Gannert1-30/+15
2016-08-01Remove statusbuf from print_battery_info.Tommie Gannert1-14/+17
2016-03-21Added status_unk to battery_infoeoin1-2/+6
2016-01-25This removes the 'remaining' time when the battery is full, since the ↵Clayton Craft1-1/+1
remaining time is always 00:00:00. When the battery is discharging, the remaining time will show up again if the user has set their format correctly.
2015-10-08Properly detect the battery charging status under FreeBSD.John Baldwin1-2/+3
The hw.acpi.battery.state sysctl returns a bitmask of flags as defined in <dev/acpica/acpiio.h>. Use constants from this header to examine the state and check for the charging flag to determine if the battery is charging.
2015-10-04Added support for lemonbarBrendan Van Hook1-9/+9
2015-05-20Clamp the percentage at 100% when last_full_capacity is enabled.Michael Stapelberg1-0/+8
2015-05-05Changed battery info output to HH:MM for consistency accross all platformsNicholas Helke1-2/+2
2015-03-16clang-format-3.5 -i **/*.[ch], update modelineMichael Stapelberg1-540/+524
From here on, we’ll use clang-format to automatically format the source. This has worked well in i3, so we are introducing it for i3status.
2014-12-22Avoid use of uninitialized variable in print_battery_infoAlexander Monakov1-1/+1
The boolean flag 'watt_as_unit' may be used without being initialized if the configured battery path does not contain expected statistics (for example if it is misconfigured and points to AC adapter info or simply an unrelated file). Even though it does not cause ill effects, it causes a warning (true positive) when running i3status under Valgrind. Initialize the variable to make code well-defined.
2014-10-07Created three individual Strings for each battery status (charging, ↵Cyril Andreatta1-4/+5
dicharching, full) Replaced hard coded status strings (CHR, BAT, FULL) in print_battery_info.c with user defined strings. The new strings are 'status_chr', 'status_bat' and 'status_full' and can be set in i3status.conf. e.g. status_chr = "⚡ CHR" If any of the new status strings is omitted the standard strings (CHR, BAT, FULL) are used.
2014-08-25Fix battery indicator on systems without POWER_SUPPLY_VOLTAGE_NOW.Klemen Košir1-2/+5
In my case, the voltage variable would stay initialized as -1, which caused the calculation of battery charge percentage to be incorrect (I would get the message that there is no battery present or even -0% charge). I have no idea how this would affect other systems, since I don't have a chance to test this.
2014-05-31Use the absolute values for (dis)charging ratesMichael Stapelberg1-3/+3
Apparently some notebooks report a negative current, whereas most don’t. fixes #1249
2014-04-30Implement battery functionality for NetBSD usersAlexander Vasarab1-0/+266
This patch takes a similar approach as the NetBSD CPU temperature code in that it uses proplib(3) to walk dictionaries supplied by envsys(4). In addition to providing the basic functionality, it: * Provides all existing format specifiers (%emptytime %consumption %status %percentage %remaining) * Respects all existing config options (hide_seconds, low_threshold, integer_battery_capacity, last_full_capacity) * Projects "time until full" when battery status is CS_CHARGING
2014-03-12Unify use of string comparisonsMats1-12/+12
* strncmp(s1, s2, strlen(s2)) → BEGINS_WITH(s1, s2) * strncmp(s1, s2, strlen(s1)) → strcmp(s1, s2) * Prefer case-insensitive comparison for options
2014-03-12For the %percentage display of batteries, drop the leading '0' for values < 10.Jasper Lievisse Adriaanse1-1/+2
2014-02-08Add hide_seconds optionIakov Davydov1-5/+13
fixes: #1134
2013-05-04fix #1017: i3status uses generic battery instanceJonas Cleve1-3/+3
2013-03-19Enable colored output for battery on FreeBSDBaptiste Daroussin1-0/+9
2013-03-09Added format_down option for battery if no battery is available.Christoph Göttschkes1-7/+7
2013-02-23battery: initialize colorful_output to falseMichael Stapelberg1-1/+1
2013-02-14Added option to show battery capacity without decimalsJulien Lequertier1-2/+6
2012-11-15DragonFlyBSD support addedScott Tincman1-2/+2
2012-10-16bugfix: colorize output even without discharge rate (thanks f8l)Simon Elsbrock1-3/+16
On some systems, the discharge rate may be missing, although the battery is still working. This leads to an edge case on Linux systems in which the output may not be colorized although a threshold was defined. This commit fixes the behavior by colorizing output if threshold_type is set to "percentage". Since we cannot calculate remaining time without discharge rate, output is still uncolorized in case of threshold_type set to "time".
2012-10-10Various fixes for the OpenBSD section of the battery backend.Jasper Lievisse Adriaanse1-8/+23
- fix the battery status printing in %status. - fix remaining time when we're charging. - use colors to indicate battery status. - small cleanups.
2012-09-05print_battery.c: do END_COLOR only if START_COLOR was usedSimon Elsbrock1-1/+5
2012-08-31Eat unnecessary space from the battery format str.Piotr Domagalski1-0/+14
If the battery is not discharging it may be not possible to give information on remaining time or consumption. The resulting strings (%remaining, %consumption, %emptytime) are empty then. But because they are in the format string, the output string contains unnecessary spaces in this case. This commit makes i3status strip these spaces.
2012-08-28add additional battery threshold type "percentage"Simon Elsbrock1-5/+12
The battery threshold can now be configured as type "time" or "percentage", but defaults to "time" to prevent unexpected behavior. Also, low_threshold was set to a more reasonable default of 30.
2012-08-13use correct units for battery calculationPhilipp Schaefer1-8/+23
2012-07-12Bugfix: Properly skip "consumption", not "consumptionbuf" (Thanks mloskot)Michael Stapelberg1-1/+1
Fixes #752
2012-07-11small style fix in src/print_battery_info.c (move comment)Michael Stapelberg1-1/+2
2012-07-11Calculate the consumption if POWER_SUPPLY_POWER_NOW does not exist in ueventMarcel Hellwig1-2/+9
2012-07-09Added consumption to battery infoMarcel Hellwig1-0/+8
2012-07-09Added condition, for red color, when battery-time is low, namely battery is ↵Marcel Hellwig1-1/+1
discharging
2012-06-11Moved translation of wireless status code to text from multiple places into ↵Mateusz Loskot1-10/+6
single BATT_STATUS_NAME macro. It simplifies customisation of the hard-wired status text.
2012-05-25colorize battery output if remaining time below thresholdSimon Elsbrock1-1/+6
2012-05-15battery info: output errors in JSON in every caseMichael Stapelberg1-4/+6
This hopefully fixes http://bugs.i3wm.org/707