chiark / gitweb /
cgi-fcgi-interp: new garbage collection approach, spec
[chiark-utils.git] / cprogs / xbatmon-simple.c
index 6ca3294248233e652bf30437f9d519c5090a1abe..5d64ff482b7f1223704db8b2bb79b13064291eb8 100644 (file)
@@ -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;