X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=blobdiff_plain;f=cprogs%2Fxbatmon-simple.c;h=5d64ff482b7f1223704db8b2bb79b13064291eb8;hp=6ca3294248233e652bf30437f9d519c5090a1abe;hb=c72a0f46e7e39f4106fc9967cd3d233e3c97b504;hpb=a3746ae37f43fdcd70ddc6f66bac37d21f3369a4 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;