-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addpkg(x11/xfce4-battery-plugin): 1.1.5 #20562
base: master
Are you sure you want to change the base?
Conversation
FILE* fp; | ||
size_t loc = 0; | ||
size_t length = 0; | ||
if ((fp = popen("termux-battery-status", "r")) == NULL) return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
termux-battery-status
may hang. It is better to kill it after a specified time if it doesn't output anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that each termux-battery-status
call is instantaneously cpu intensive. Would it be a better idea to rewrite to launch a long standing JVM instance for monitoring battery level? That should also resolve the time lag issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you measure it? Are you using a termux-app version with termux-am-socket? Check if $TERMUX_APP__AM_SOCKET_SERVER_ENABLED
is exported and set to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used #20393. can be observed running termux-battery-status
. or top -d 0.25
shows similar result, but top -d 0.5
does not.
$TERMUX_APP__AM_SOCKET_SERVER_ENABLED
is not set, where to do that? Or just TERMUX_APP__AM_SOCKET_SERVER_ENABLED=true termux-battery-status
? Or somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it requires termux-app 0.119.0-beta1 from github or fdroid, and a recent termux-api app version as well. termux-app should then automatically export that var and use termux-am-socket if it exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, dev members! If BroadcastReceiver
is not feasible, I will choose between termux-battery-status
(requires Termux:API
+termux-api
and implementing timeout reading output, but there is official support) and app_process
with BatteryManager
.
For the latter app_process
approach, my only question left is perhaps how can JVM instance communicate back to the native code process. I suppose app_process
creates a new Java process, so probably callback or JNI won't work and it will need IPC. Am I right and any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it be a plan or even posisble to use a real Android context in Termux Java? What hinders it, Android package policy?
I am intereted because:
- currently adding Android features to Termux requires changes to Termux:App or Temrux:API which can be very slow to make it official.
- Termux:API seems to mostly provide command line interface for terminal users, but not for native program in termux package or perhaps need
popen()
everytime. - still, the
app_process
approach comes with quite many limitations.
It is a bit off-topic to this PR, would it be feasible to implement below features with app_process
:
- any
startActivityForResult()
equivalence? I know there is somestartActivity()
equivalence inTermuxAm
but how aboutActivityForResult()
? - any way to open a WebView? It is indeed a highly demanded feature (mentioned many times in reddit). I know about
Termux:GUI
but looks like a overkill for many users need who just want to beatifully show their locally hosted webpage, e.g. running a command liketermux-webview http://localhost:8888
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so probably callback or JNI won't work and it will need IPC. Am I right and any suggestions?
JNI does not need IPC or something to work. It is a feature of JVM. Termux-x11 works with JNI without any issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
real Android context in Termux Java?
It is only possible in the case if termux's service will instantiate new JVM with custom APK loading. Probably agnostic-apollo can implement that, but this will make coming back to google play impossible.
any startActivityForResult() equivalence
What exactly you need? Your end goal. In the case of app_process started process it is not possible, but in the case if you want establish connection with your app you can use some Binder+broadcast workaround.
any way to open a WebView
You can open webpage in chrome or other browser with termux-open
or am start
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context usage will be supported in future with use of reflection APIs, like how Tasker app allows running random java code with Java Function
action. startActivityForResult()
is not something too difficult and can maybe even be added to termux-am-socket
, but maybe in Termux:API redesign where service will be used to keep asynchronous connections. WebView support has already been implemented for Media viewer APIs written for viewing (termux) docs, etc locally, but they aren't complete yet, and will be provided in future Termux app versions.
Based on
termux-battery-status
fromtermux-api
. Not perfect, with 30 sec delay by design, but at least available to users who is using DE in full screen.Showcase