FreeBSD Bugzilla – Attachment 231894 Details for
Bug 262018
x11/lumina-core: Support battery monitoring on non-x86 systems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to fix battery monitoring on non-x86
lumina-core-battery.patch (text/plain), 5.01 KB, created by
Jason W. Bacon
on 2022-02-17 15:35:56 UTC
(
hide
)
Description:
Patch to fix battery monitoring on non-x86
Filename:
MIME Type:
Creator:
Jason W. Bacon
Created:
2022-02-17 15:35:56 UTC
Size:
5.01 KB
patch
obsolete
>diff -ruN --exclude=CVS --exclude=.svn /usr/ports/x11/lumina-core/Makefile /usr/ports/wip/lumina-core/Makefile >--- /usr/ports/x11/lumina-core/Makefile 2022-01-29 17:43:15.852279000 -0600 >+++ /usr/ports/wip/lumina-core/Makefile 2022-02-17 09:34:17.206892000 -0600 >@@ -3,7 +3,7 @@ > PORTNAME= lumina-core > DISTVERSIONPREFIX= v > DISTVERSION= 1.6.2 >-PORTREVISION= 1 >+PORTREVISION= 2 > CATEGORIES= x11 > > MAINTAINER= lbartoletti@FreeBSD.org >diff -ruN --exclude=CVS --exclude=.svn /usr/ports/x11/lumina-core/files/patch-.._src-qt5_src-cpp_framework-OSInterface-FreeBSD.cpp /usr/ports/wip/lumina-core/files/patch-.._src-qt5_src-cpp_framework-OSInterface-FreeBSD.cpp >--- /usr/ports/x11/lumina-core/files/patch-.._src-qt5_src-cpp_framework-OSInterface-FreeBSD.cpp 1969-12-31 18:00:00.000000000 -0600 >+++ /usr/ports/wip/lumina-core/files/patch-.._src-qt5_src-cpp_framework-OSInterface-FreeBSD.cpp 2022-02-17 08:46:35.981099000 -0600 >@@ -0,0 +1,44 @@ >+--- ../src-cpp/framework-OSInterface-FreeBSD.cpp.orig 2021-12-25 20:33:45.000000000 -0600 >++++ ../src-cpp/framework-OSInterface-FreeBSD.cpp 2022-02-17 08:14:20.413578000 -0600 >+@@ -21,24 +21,34 @@ >+ bool OSInterface::OS_batteryAvailable(){ >+ static int bat_avail = -1; //this will not change during a single session - keep later calls fast >+ if(bat_avail < 0){ >+- int val = getCmdOutput("apm -l").join("").toInt(); >+- bat_avail = ((val >= 0 && val <= 100) ? 1 : 0 ); >++ bat_avail = (sysctlbyname("hw.acpi.battery.life", &life, &len, NULL, 0) == 0); >+ } >+ return (bat_avail==1); >+ } >+ >+ float OSInterface::OS_batteryCharge(){ >+- int charge = getCmdOutput("apm -l").join("").toInt(); >+- if(charge > 100){ charge = -1; } //invalid charge >+- return charge; >++ int life; >++ if ( (sysctlbyname("hw.acpi.battery.life", &life, &len, NULL, 0) != 0) || >++ (life > 100) ) >++ life = -1 >++ return life; >+ } >+ >+ bool OSInterface::OS_batteryCharging(){ >+- return (getCmdOutput("apm -a").join("").simplified() == "1"); >++ if ( (sysctlbyname("hw.acpi.battery.state", &state, &len, NULL, 0) == 0) && >++ (state == ACPI_BATT_STAT_CHARGING) ) >++ return true; >++ else >++ return false; >+ } >+ >+ double OSInterface::OS_batterySecondsLeft(){ //Returns: estimated number of seconds remaining >+- return getCmdOutput("apm -t").join("").toDouble(); >++ int min, sec; >++ if ( sysctlbyname("hw.acpi.battery.time", &min, &len, NULL, 0) == 0 ) >++ sec = min * 60; >++ else >++ sec = -1 >++ return sec; >+ } >+ >+ // = Volume = >diff -ruN --exclude=CVS --exclude=.svn /usr/ports/x11/lumina-core/files/patch-libLumina_LuminaOS-FreeBSD.cpp /usr/ports/wip/lumina-core/files/patch-libLumina_LuminaOS-FreeBSD.cpp >--- /usr/ports/x11/lumina-core/files/patch-libLumina_LuminaOS-FreeBSD.cpp 1969-12-31 18:00:00.000000000 -0600 >+++ /usr/ports/wip/lumina-core/files/patch-libLumina_LuminaOS-FreeBSD.cpp 2022-02-17 08:45:49.313109000 -0600 >@@ -0,0 +1,71 @@ >+--- libLumina/LuminaOS-FreeBSD.cpp.orig 2021-12-26 02:33:45 UTC >++++ libLumina/LuminaOS-FreeBSD.cpp >+@@ -9,6 +9,7 @@ >+ #include <unistd.h> >+ #include <sys/types.h> >+ #include <sys/sysctl.h> >++#include <dev/acpica/acpiio.h> >+ >+ #include <QDebug> >+ //can't read xbrightness settings - assume invalid until set >+@@ -289,31 +290,52 @@ void LOS::systemSuspend(){ >+ } >+ >+ //Battery Availability >++// apm command is not available on powerpc or arm >+ bool LOS::hasBattery(){ >+ static int hasbat = -1; >++ int life; >++ size_t len = sizeof(life); >+ if(hasbat < 0 ){ >+- int val = batteryCharge(); >+- if(val >= 0 && val <= 100){ hasbat = 1; } >+- else{ hasbat = 0; } >++ if ( sysctlbyname("hw.acpi.battery.life", &life, &len, NULL, 0) == 0 ) >++ hasbat = 1; >++ else >++ hasbat = 0; >+ } >+ return (hasbat==1); >+ } >+ >+ //Battery Charge Level >++// apm command is not available on powerpc or arm >+ int LOS::batteryCharge(){ //Returns: percent charge (0-100), anything outside that range is counted as an error >+- int charge = LUtils::getCmdOutput("apm -l").join("").toInt(); >+- if(charge > 100){ charge = -1; } //invalid charge >+- return charge; >++ int life; // sysctl name >++ size_t len = sizeof(life); >++ if ( (sysctlbyname("hw.acpi.battery.life", &life, &len, NULL, 0) != 0) || >++ (life > 100) ) >++ life = -1; //invalid charge >++ return life; >+ } >+ >+ //Battery Charging State >++// apm command is not available on powerpc or arm >+ bool LOS::batteryIsCharging(){ >+- return (LUtils::getCmdOutput("apm -a").join("").simplified() == "1"); >++ int state; >++ size_t len = sizeof(state); >++ if ( (sysctlbyname("hw.acpi.battery.state", &state, &len, NULL, 0) == 0) && >++ (state == ACPI_BATT_STAT_CHARGING) ) >++ return true; >++ else >++ return false; >+ } >+ >+ //Battery Time Remaining >++// apm command is not available on powerpc or arm >+ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining >+- return LUtils::getCmdOutput("apm -t").join("").toInt(); >++ int min; >++ size_t len = sizeof(min); >++ if ( sysctlbyname("hw.acpi.battery.time", &min, &len, NULL, 0) == 0 ) >++ return min * 60; >++ else >++ return -1; >+ } >+ >+ //File Checksums
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 262018
: 231894