From f7991ca3eb3da83c3d3181a72cc3ba68c5736b95 Mon Sep 17 00:00:00 2001 From: John Lindgren Date: Fri, 30 Nov 2018 23:21:08 -0500 Subject: [PATCH 4/7] Linux: Allow normal startup if either AC adapter or battery is found. --- panel-plugin/libacpi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/panel-plugin/libacpi.c b/panel-plugin/libacpi.c index df05185..0f524ca 100644 --- a/panel-plugin/libacpi.c +++ b/panel-plugin/libacpi.c @@ -200,6 +200,9 @@ int check_acpi_sysfs(void) char typepath[128]; char tmptype[8]; + acpi_sysfs = 0; + batt_count = 0; + sysfs = opendir("/sys/class/power_supply"); if (sysfs == 0) { @@ -221,6 +224,7 @@ int check_acpi_sysfs(void) fclose(typefile); if(strncmp("Battery", tmptype, 7)==0) { + acpi_sysfs = 1; sprintf(batteries[batt_count], "/sys/class/power_supply/%s", name); #ifdef DEBUG printf("DBG:battery number %d at:\n",batt_count); @@ -231,6 +235,7 @@ int check_acpi_sysfs(void) } /* I guess that the type of the AC adapter is always "Mains" (?) */ else if(strncmp("Mains", tmptype, 5)==0){ + acpi_sysfs = 1; sprintf(sysfsacdir, "/sys/class/power_supply/%s", name); #ifdef DEBUG printf("DBG:sysfs AC dir->%s\n",sysfsacdir); @@ -239,17 +244,15 @@ int check_acpi_sysfs(void) } } closedir(sysfs); - if ( batt_count == 0 ) + if ( acpi_sysfs == 0 ) { #ifdef DEBUG printf("DBG:No acpi support for sysfs.\n"); #endif - acpi_sysfs = 0; return 2; } else { - acpi_sysfs = 1; return 0; } } -- 2.19.1