summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2020-08-20 14:13:07 +1000
committerNathan Scott <nathans@redhat.com>2020-08-20 14:13:07 +1000
commitcdff8aea2ab10870af1aad5bdb6949ea0fd407b0 (patch)
tree5fc420f7745c5a734bb59a99f897f61ba1dd59b1 /linux
parentb30c22d687e692fb2a16ce50d491f3d724301af5 (diff)
parent1886117c721c4d66a61f58bbfe5367e6fc527367 (diff)
Merge branch 'hishamhm-pull-946'
Diffstat (limited to 'linux')
-rw-r--r--linux/Battery.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/linux/Battery.c b/linux/Battery.c
index aedacabc..029eff59 100644
--- a/linux/Battery.c
+++ b/linux/Battery.c
@@ -193,7 +193,18 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
char* entryName = (char *) dirEntry->d_name;
const char filePath[50];
- if (entryName[0] == 'B' && entryName[1] == 'A' && entryName[2] == 'T') {
+ xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName);
+ int fd = open(filePath, O_RDONLY);
+ if (fd == -1)
+ continue;
+
+ char type[8];
+ ssize_t typelen = xread(fd, type, 7);
+ close(fd);
+ if (typelen < 1)
+ continue;
+
+ if (type[0] == 'B' && type[1] == 'a' && type[2] == 't') {
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName);
int fd = open(filePath, O_RDONLY);

© 2014-2024 Faster IT GmbH | imprint | privacy policy