[Pkg-wmaker-commits] [wmbattery] 96/241: some additional changes
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:37:39 UTC 2015
- Previous message: [Pkg-wmaker-commits] [wmbattery] 95/241: * Add support for the new ACPI_SYSFS_POWER kernel interface in 2.6.24. (Still quite rough and probably gets a few things wrong.) Closes: #456247
- Next message: [Pkg-wmaker-commits] [wmbattery] 97/241: * Bit the bullet, stopped trying to track the kernel's ever changing interfaces, and added support for querying battery information from hal. Support for the old kernel interfaces (APM, ACPI, etc) is still present, but to use new interfaces such 2.6.24's /sys/class/power_adapter, you'll have to have dbus and hal. Closes: #456247, #246641, #290712, #393616, #456248 * Fix -e option.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmbattery.
commit 7a378ddd1d3255049721f38a5a13e9ff3bbf1360
Author: Joey Hess <joey at kodama.kitenet.net>
Date: Fri Feb 1 18:43:55 2008 -0500
some additional changes
---
sys_power.c | 49 +++++++++++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 16 deletions(-)
diff --git a/sys_power.c b/sys_power.c
index 30c66ed..95dc8cc 100644
--- a/sys_power.c
+++ b/sys_power.c
@@ -173,11 +173,16 @@ int sys_power_read (int battery, apm_info *info) {
/* Work out if the battery is present, and what percentage of full
* it is and how much time is left. */
if (strcmp(get_sys_power_value(sys_power_batt_dirs[battery], "present"), "1") == 0) {
- int charge = atoi(get_sys_power_value(sys_power_batt_dirs[battery], "charge_now"));
- int current = atoi(get_sys_power_value(sys_power_batt_dirs[battery], "current_now"));
+ int charge, current;
+
+ charge = atoi(get_sys_power_value(sys_power_batt_dirs[battery], "charge_now"));
+ /* Use average if it's available. */
+ current = atoi(get_sys_power_value(sys_power_batt_dirs[battery], "current_avg"));
+ if (! current)
+ current = atoi(get_sys_power_value(sys_power_batt_dirs[battery], "current_now"));
if (current) {
- /* time remaining = (charge / current) */
+ /* time remaining = (current_capacity / discharge rate) */
info->battery_time = (float) charge / (float) current * 60;
}
else {
@@ -198,23 +203,44 @@ int sys_power_read (int battery, apm_info *info) {
* capacity. Rescan for a new max capacity. */
sys_power_batt_capacity[battery] = get_sys_power_batt_capacity(battery);
}
+
+ if (current && sys_power_batt_capacity[battery]) {
+ /* percentage = (current_capacity / max capacity) * 100 */
+ info->battery_percentage = (float) current / (float) sys_power_batt_capacity[battery] * 100;
+ }
+ else {
+ info->battery_percentage = -1;
+ }
status = get_sys_power_value(sys_power_batt_dirs[battery], "status");
- if (strcmp(status, "Discharging") == 0) {
+ if (strcasecmp(status, "discharging") == 0) {
info->battery_status = BATTERY_STATUS_CHARGING;
/* Explicit power check used here
* because AC power might be on even if a
* battery is discharging in some cases. */
info->ac_line_status = sys_power_on_ac();
+ if (! info->ac_line_status) {
+ /* Check for critical or low status. */
+ if (info->battery_percentage < 1) {
+ info->battery_status = BATTERY_STATUS_CRITICAL;
+ }
+ else if (info->battery_percentage <= 10) {
+ info->battery_status = BATTERY_STATUS_LOW;
+ }
+ }
}
- else if (strcmp(status, "Charging") == 0) {
+ else if (strcasecmp(status, "charging") == 0) {
info->battery_status = BATTERY_STATUS_CHARGING;
info->ac_line_status = 1;
info->battery_flags = info->battery_flags | BATTERY_FLAGS_CHARGING;
- if (current)
+ printf("charging; max cap: %i, charge: %i, current: %i\n", sys_power_batt_capacity[battery], charge, current);
+ if (current) {
info->battery_time = -1 * (float) (sys_power_batt_capacity[battery] - charge) / (float) current * 60;
- else
+ printf("time est: %i\n", info->battery_time);
+ }
+ else {
info->battery_time = 0;
+ }
if (abs(info->battery_time) < 0.5)
info->battery_time = 0;
}
@@ -222,15 +248,6 @@ int sys_power_read (int battery, apm_info *info) {
fprintf(stderr, "unknown battery status: %s\n", status);
info->battery_status = BATTERY_STATUS_ABSENT;
}
-
- if (current && sys_power_batt_capacity[battery]) {
- /* percentage = (current_capacity / max capacity) * 100 */
- info->battery_percentage = (float) current / (float) sys_power_batt_capacity[battery] * 100;
- }
- else {
- info->battery_percentage = -1;
- }
-
}
else {
info->battery_percentage = 0;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git
- Previous message: [Pkg-wmaker-commits] [wmbattery] 95/241: * Add support for the new ACPI_SYSFS_POWER kernel interface in 2.6.24. (Still quite rough and probably gets a few things wrong.) Closes: #456247
- Next message: [Pkg-wmaker-commits] [wmbattery] 97/241: * Bit the bullet, stopped trying to track the kernel's ever changing interfaces, and added support for querying battery information from hal. Support for the old kernel interfaces (APM, ACPI, etc) is still present, but to use new interfaces such 2.6.24's /sys/class/power_adapter, you'll have to have dbus and hal. Closes: #456247, #246641, #290712, #393616, #456248 * Fix -e option.
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Pkg-wmaker-commits
mailing list