[Xfce4-commits] [panel-plugins/xfce4-battery-plugin] 04/07: Linux: Allow normal startup if either AC adapter or battery is found.

noreply at xfce.org noreply at xfce.org
Sun Dec 2 22:36:31 CET 2018


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-battery-plugin.

commit 9d0c905d3af56e55a589cb057766ba4164620151
Author: John Lindgren <john at jlindgren.net>
Date:   Fri Nov 30 23:21:08 2018 -0500

    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;
 	}
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list