X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=cprogs%2Fxbatmon-simple.c;h=5d64ff482b7f1223704db8b2bb79b13064291eb8;hb=8e6155d320853755d140f0cbd70399cf543cd31d;hp=62a7f258fbb6590ba7318eb786cb7c0cb7bfd7eb;hpb=6444170853205dadd8862ae79a86e99d83d58a85;p=chiark-utils.git diff --git a/cprogs/xbatmon-simple.c b/cprogs/xbatmon-simple.c index 62a7f25..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; @@ -532,7 +542,7 @@ static const char *getresource(const char *want) { sprintf(class_buf,"Xacpi-Simple.%s",want); r= XrmGetResource(xrm, name_buf,class_buf, &rep_type_dummy, &val); - if (!r) return val.addr; + if (r) return val.addr; return 0; }