Closed numberokta closed 8 months ago
Not a bug. Android restricts background clipboard access.
Not a bug. Android restricts background clipboard access.
So is there any way?
Currently there is no way.
You can swipe additional keyboard of termux-x11 and paste there. Better than nothing.
I think there is some ways to do that, somethings like create an api for termux-x11 to run shell command directly through termux-x11
It's better to use broadcast and implement a function like this
termux-am broadcast --user 0 -a com.termux.x11.CHANGE_PREFERENCE -p com.termux.x11 -e list null
and use it like this
termux-am broadcast --user 0 -a com.termux.x11.CHANGE_PREFERENCE -p com.termux.x11 -e exec "some code"
to execute shell code directly through termux-x11 in that environment that has already been logged in. If you agree with this, i think this issue must be moved to termux-x11 as enhancement.
Closing in prior to #452
I think this way is worth to trying as termux-api
and doesn't need to root or adb access.
I read all of them, and the solutions that you were talking about depend on adb or root access. I know this issue isn't limited to termux-x11, but it can be easily fixed on termux-x11 by implementing some java code to get clipboard text from android with broadcasting and also set clipboard text directly through termux-x11 with broadcasting without any api. I know that termux-x11 is xserver, but it's working on android, and it would be nice to communicate between android and linux clipboards directly.
It's better to use broadcast and implement a function like this
termux-am broadcast --user 0 -a com.termux.x11.CHANGE_PREFERENCE -p com.termux.x11 -e list null
The problem is that in this case termux-clipboard-get
will not be fixed, it will be other workaround. It will not be integrated to termux-api
because termux plugins do not communicate this way.
If you need to get automatic way to get clipboard when Termux:X11 is in foreground I think I found a way. But implementing it will require some time.
Yes, termux-clipboard-get
will not be fixed and it will be a new feature
for termux-x11
and not related to termux-api
, actually i think there is no way to get clipboard with termux-api without adb or root access cause android restricted that. But in termux-x11, It's simple task, just manage (get, set) clipboard between android and termux directly through termux-x11 with broadcasting, something like this
termux-am broadcast --user 0 -a com.termux.x11.CHANGE_PREFERENCE -p com.termux.x11 -e clipboard_get null
termux-am broadcast --user 0 -a com.termux.x11.CHANGE_PREFERENCE -p com.termux.x11 -e clipboard_set "hello world"
My first idea was that to execute shell code directly through termux-x11 and use termux-clipboard-get
this way. In this way we can use functionality that need us to be present in app to work otherwise android restricted that.
termux-am broadcast --user 0 -a com.termux.x11.CHANGE_PREFERENCE -p com.termux.x11 -e exec "shell code"
But clipboard_get is also good and work
termux-am broadcast --user 0 -a com.termux.x11.CHANGE_PREFERENCE -p com.termux.x11 -e clipboard_set "hello world"
That usecase is definitely out of scope of X server. AFAIK clipboard modification is not restricted, only retrieving current clipboard content. So in the case of termux-api it should work even in background.
termux-am broadcast --user 0 -a com.termux.x11.CHANGE_PREFERENCE -p com.termux.x11 -e clipboard_get null
The only way of clipboard access I can accept is mixing X11 and Android clipboard. Getting current clipboard content through broadcasts is out of scope of X server and will not be implemented. I will not repeat it again.** Mixing clipboard means to let X11 modify Android clipboard and let Android modify X11 clipboard (at least when Termux:X11 comes foreground). Currently it is not implemented because background clipboard access is restricted, so Android application can not receive notification (event) about clipboard change so termux-x11 can not decide which clipboard selection is newer and when it really should get Android's clipboard content and send it to X server. I've found some workaround and now working on it.
Okay, do whatever you think is best. I gladly wait for it.
Problem description
termux-clipboard-get works in proot-distro from temux cli but does not in terminal from termux-x11 Steps to reproduce
https://github.com/termux/termux-api/assets/20727200/a14d1855-18ea-4686-a28e-eaff7e93c02b
Expected behavior
it must work. Additional information