From: Ian Jackson Date: Wed, 4 Sep 2013 20:27:49 +0000 (+0100) Subject: Make xbatmon-simple tolerate the lack of "type" in power supply uevent fields, by... X-Git-Tag: debian/4.2.1__iwj2~19 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=ad3bdcc45dbe8224f16bb65b06102be3652e8685 Make xbatmon-simple tolerate the lack of "type" in power supply uevent fields, by guessing the type from the presence or absence of "present" (which appears for batteries) and "online" (which appears for mains). Closes: #689134. --- diff --git a/cprogs/xbatmon-simple.c b/cprogs/xbatmon-simple.c index 6ca3294..5d64ff4 100644 --- a/cprogs/xbatmon-simple.c +++ b/cprogs/xbatmon-simple.c @@ -326,6 +326,16 @@ ALL_VARS(V_NOTFOUND) ALL_DIRECT_VARS(V_PRINT) } + if (this_type == -1) { + /* some kernels don't seem to provide TYPE in the uevent + * guess the type from whether we see "present" or "online" */ + if (this_online >= 0 && this_present == -1) this_type = TYPE_MAINS; + if (this_online == -1 && this_present >= 0) this_type = TYPE_BATTERY; + if (debug) + printf(" type absent from uevent %6s guessed %12s %"PRId64"\n", + "", "", this_type); + } + int needsfields_MAINS = this_type == TYPE_MAINS; int needsfields_BATTERY = this_type == TYPE_BATTERY; int needsfields_BOTH = 1; diff --git a/debian/changelog b/debian/changelog index 02b4972..8db8616 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +chiark-utils (4.2.1~~iwj) unstable; urgency=low + + * Make xbatmon-simple tolerate the lack of "type" in power supply uevent + fields, by guessing the type from the presence or absence of "present" + (which appears for batteries) and "online" (which appears for mains). + Closes: #689134. + + -- Ian Jackson Sat, 29 Sep 2012 13:47:21 +0100 + chiark-utils (4.2.0) unstable; urgency=low * Rename `xacpi-simple' to `xbatmon-simple':