panel: added sysfs support
PATCH v2 1/1 panel: added sysfs support
battery applet supports reading battery and supply information from sysfs entries, /sys/class/power_supply/.
[YOCTO #12904]
https://bugzilla.yoctoproject.org/show_bug.cgi?id=12904
--- applets/battery/Makefile.am | 4 + applets/battery/battery-sysfs.c | 155 ++++++++++++++++++++++++++++++++ applets/battery/battery.h | 5 +- configure.ac | 4 + 4 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 applets/battery/battery-sysfs.c
applets/battery/Makefile.am +4 -0
@@ -5,6 +5,10 @@ applet_LTLIBRARIES = libbattery.la libbattery_la_SOURCES = battery.c battery.h libbattery_la_CPPFLAGS = $(AM_CPPFLAGS) -DDATADIR=\"$(pkgdatadir)/battery/\" +if HAVE_SYSFS +libbattery_la_SOURCES += battery-sysfs.c +endif + if HAVE_LIBAPM libbattery_la_LIBADD = -lapm libbattery_la_SOURCES += battery-apm.c
applets/battery/battery-sysfs.c new file +155 -0
155 lines not on this page · raw message
applets/battery/battery.h +4 -1
@@ -6,8 +6,11 @@#ifndef MB_APPLET_BATTERY_H #define MB_APPLET_BATTERY_H - +#include <stdio.h> #include <string.h> +#include <stdlib.h> +#include <sys/types.h> +#include <dirent.h> int pm_support (void );const char *pm_battery_icon (void );
configure.ac +4 -0
@@ -61,6 +61,9 @@ AC_ARG_WITH( ) case "$with_battery" in + "sysfs") enable_linux_sysfs=yes + enable_battery=yes + ;; "acpi") AC_CHECK_HEADERS(libacpi.h, enable_linux_acpi=yes, AC_MSG_FAILURE([You need to install libacpi])) enable_battery=yes ;;
@@ -75,6 +78,7 @@ esac AM_CONDITIONAL(HAVE_BATTERY, test x$enable_battery = xyes) AM_CONDITIONAL(HAVE_LIBAPM, test x$enable_linux_apm = xyes) AM_CONDITIONAL(HAVE_LIBACPI, test x$enable_linux_acpi = xyes) +AM_CONDITIONAL(HAVE_SYSFS, test x$enable_linux_sysfs = xyes) # glib-genmarshal GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
Signature · 1 line
2.43.0
Hello Dixit,
This looks fine, except for one point.
applets/battery/battery-sysfs.c line 9
Quoted 11 lines · Dixit Parmar via lists.yoctoproject.org
+++
b/applets/battery/battery-sysfs.capplets/battery/battery-sysfs.c new file +9
-0@@ -0,0 +1,155 @@ +/* +* (C) 2008 Intel. +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* Licensed under the GPL v2 or greater. +*/ + +#include "battery.h"
The origin and copyright of this new file needs to be explained. Have you written it yourself or was it copied partly or wholly from a different place? If so, why does it have an Intel copyright dating to 2008?
If you've written it yourself, was it done as part of your work duties, and if so, should the copyright be assigned to your employer?
Alex
Hi Alex,
Thank you for review. from what I understood from your comment,
The file[battery-sysfs.c] was created solely by me as an individual contributor, out of my work duties with my employer.
The file header(along with copyright details) is copied straight away from the same codebase's existing file: https://git.yoctoproject.org/matchbox-panel-2/tree/applets/battery/battery-acpi.c. ( https://git.yoctoproject.org/matchbox-panel-2/tree/applets/battery/battery-acpi.c ) I am not good with the licensing terms, so I am not exactly sure what the correct one should be. Pls guide me for correct header. Thanks,
Dixit
Quoted 3 lines · Dixit Parmar via lists.yoctoproject.org
Thank you for review. from what I understood from your comment,
The file[battery-sysfs.c] was created solely by me as an individual contributor, out of my work duties with my employer.
The file header(along with copyright details) is copied straight away from the same codebase's existing file: https://git.yoctoproject.org/matchbox-panel-2/tree/applets/battery/battery-acpi.c. I am not good with the licensing terms, so I am not exactly sure what the correct one should be. Pls guide me for correct header.
I think
(C) Dixit Parmar
is fine. No need for the year.
Alex
Quoted 7 lines · Alexander Kanavin
Quoted 3 lines
Thank you for review. from what I understood from your comment,
The file[battery-sysfs.c] was created solely by me as an individual contributor, out of my work duties with my employer.
The file header(along with copyright details) is copied straight away from the same codebase's existing file: https://git.yoctoproject.org/matchbox-panel-2/tree/applets/battery/battery-acpi.c. I am not good with the licensing terms, so I am not exactly sure what the correct one should be. Pls guide me for correct header.I think
(C) Dixit Parmar
is fine. No need for the year.
And the rest of the header should be as it is.
Alex
Alex, Okay, thanks. If you have some examples handy, can you show them (mentioning the personal copyrights)?
Quoted 2 lines · Dixit Parmar via lists.yoctoproject.org
Alex, Okay, thanks. If you have some examples handy, can you show them (mentioning the personal copyrights)?
You can find them anywhere. For example in Linux kernel:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/kernel/irq.c
The important thing is that it must say who holds the copyright, and what the license is (in the form of spdx identifier). If you add to an existing project, the license should follow the rest of the project.
Alex
Thanks Alex, I have pushed v3 patch with the suggested modification.
Thanks, v3 looks good. We don't really have maintainers for these items, but hopefully Ross can pick it up and push to repo.
Alex
Quoted 12 lines · Dixit Parmar via lists.yoctoproject.org
Thanks Alex, I have pushed v3 patch with the suggested modification. _._,_._,_
________________________________
Links:You receive all messages sent to this group.
View/Reply Online (#741) | Reply To Group | Reply To Sender | Mute This Topic | New Topic Your Subscription | Contact Group Owner | Unsubscribe [[email protected]]
_._,_._,_