]> git.sur5r.net Git - i3/i3status/blobdiff - src/print_battery_info.c
battery: implement "path" option for batteries with non-standard paths
[i3/i3status] / src / print_battery_info.c
index c806493bd46253cd72530620623281541855321e..6ee89896cfed8c0e226e7a9bb77dcc2e19bc354d 100644 (file)
@@ -17,7 +17,7 @@
  * worn off your battery is.
  *
  */
-void print_battery_info(int number, const char *format, bool last_full_capacity) {
+void print_battery_info(int number, const char *path, const char *format, bool last_full_capacity) {
         time_t empty_time;
         struct tm *empty_tm;
         char buf[1024];
@@ -38,7 +38,7 @@ void print_battery_info(int number, const char *format, bool last_full_capacity)
 
 #if defined(LINUX)
         static char batpath[512];
-        sprintf(batpath, "/sys/class/power_supply/BAT%d/uevent", number);
+        sprintf(batpath, path, number);
         if (!slurp(batpath, buf, sizeof(buf))) {
                 printf("No battery");
                 return;
@@ -58,6 +58,8 @@ void print_battery_info(int number, const char *format, bool last_full_capacity)
                         remaining = atoi(walk+1);
                 else if (BEGINS_WITH(last, "POWER_SUPPLY_CURRENT_NOW"))
                         present_rate = atoi(walk+1);
+                else if (BEGINS_WITH(last, "POWER_SUPPLY_POWER_NOW"))
+                        present_rate = atoi(walk+1);
                 else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Charging"))
                         status = CS_CHARGING;
                 else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Full"))