这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/debug_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
- name: Build
run: |
./gradlew assembleDebug
- name: Build companion package
run: |
./build_termux_package
- name: Store generated APK file
uses: actions/upload-artifact@v2
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ Thumbs.db

#files containing github tokens
github.properties

*.cxx
app/.cxx/*
81 changes: 72 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

# Termux:X11

[![Join the chat at https://gitter.im/termux/termux](https://badges.gitter.im/termux/termux.svg)](https://gitter.im/termux/termux)

A [Termux](https://termux.com) add-on app providing Android frontend for Xwayland.

When developing (or packaging), note that this app needs to be signed with the same key as the main Termux app in order to have the permission to execute scripts.

## About
Termux:X11 uses [Wayland](https://wayland.freedesktop.org/) display protocol. a modern replacement and the predecessor of the [X.org](https://www.x.org/wiki) server
Termux:X11 uses [Wayland](https://wayland.freedesktop.org/) display protocol. a modern replacement and the predecessor of the [X.org](https://www.x.org/wiki) server.
Pay attention that it is not a full-fledged Wayland server and it can not handle Wayland apps except Xwayland.

## How does it work?
the Termux:X11 app writes files through `$PREFIX/tmp` in Termux directory by default and creates wayland sockets through that directory, this takes advantage of `sharedUserId` AndroidManifest attribute
The Termux:X11 app's companion package executable creates socket through `$XDG_RUNTIME_DIR` in Termux directory by default.

the wayland sockets is the way for the graphical applications to communicate with. Termux X11 applications do not have wayland support yet, this kind of setup may not be straightforward and therefore additional packages should be installed in order for X11 applications to be run in Termux:X11
The wayland sockets is the way for the graphical applications to communicate with. Termux X11 applications do not have wayland support yet, this kind of setup may not be straightforward and therefore additional packages should be installed in order for X11 applications to be run in Termux:X11

## Setup Instructions
for this one. you must enable the `x11-repo` repository can be done by executing `pkg install x11-repo` command
For this one. you must enable the `x11-repo` repository can be done by executing `pkg install x11-repo` command

for X applications to work, you must install `Xwayland` packages. you can do that by doing
For X applications to work, you must install Termux-x11 companion package. You can do that by doing
```
pkg install xwayland
pkg install termux-x11
```

## Running Graphical Applications
Expand All @@ -28,7 +28,7 @@ to work with GUI applications, start Termux:X11 first. a toast message saying `S
then you can start your desired graphical application by doing:
```
~ $ export XDG_RUNTIME_DIR=${TMPDIR}
~ $ Xwayland :1 >/dev/null &
~ $ termux-x11 :1 >/dev/null &
~ $ env DISPLAY=:1 xfce4-session
```
You may replace `xfce4-session` if you use other than Xfce
Expand All @@ -42,5 +42,68 @@ You can fix this in your window manager settings (in the case of xfce4 and lxqt

![image](./img/dpi-scale.png)

## Using with 3rd party apps
It is posssible to use Termux:X11 with 3rd party apps.
You should start Termux:X11's activity with providing some additional data.
```
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import com.termux.x11.common.ITermuxX11Internal;
...
private final String TermuxX11ComponentName = "com.termux.x11/.TermuxX11StarterReceiver";

private void startTermuxX11() {
Service svc = new Service();
Bundle bundle = new Bundle();
bundle.putBinder("", svc);

Intent intent = new Intent();
intent.putExtra("com.termux.x11.starter", bundle);
ComponentName cn = ComponentName.unflattenFromString(TermuxX11ComponentName);
if (cn == null)
throw new IllegalArgumentException("Bad component name: " + TermuxX11ComponentName);

intent.setComponent(cn);

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
}

class Service extends ITermuxX11Internal.Stub {
@Override
public ParcelFileDescriptor getWaylandFD() throws RemoteException {
/*
* nativeObtainWaylandFd() should create wayland-0
* socket in your $XDG_RUNTIME_DIR and return it's
* fd. You should not "listen()" this socket.
*/
int fd = nativeObtainWaylandFd();
return ParcelFileDescriptor.adoptFd(fd);
}

@Override
public ParcelFileDescriptor getLogFD() throws RemoteException {
/*
* nativeObtainLogFd() should create file that should
* contain log. Pay attention that if you choose tty/pty
* or fifo file Android will not allow writing it.
* You can use `pipe` system call to create pipe.
* Do not forget to change it's mode with `fchmod`.
*/
int fd = nativeObtainLogFd();
return ParcelFileDescriptor.adoptFd(fd);
}

@Override
public void finish() throws RemoteException {
/*
* Termux:X11 cals this function to to notify calling
* process that init stage was completed
* successfully.
*/
}
}
```

# License
Released under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.html).
11 changes: 9 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ android {
defaultConfig {
applicationId "com.termux.x11"
minSdkVersion 24
//noinspection OldTargetApi
targetSdkVersion 28
versionCode 7
versionName "1.02.04"
versionCode 9
versionName "1.02.06"
}

signingConfigs {
Expand All @@ -30,6 +31,11 @@ android {
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

externalNativeBuild {
ndkBuild {
path "src/main/jni/Android.mk"
Expand All @@ -47,6 +53,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation project(path: ':common')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
17 changes: 9 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.termux.x11"
android:installLocation="internalOnly"
android:sharedUserId="com.termux">
>

<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"
Expand All @@ -18,16 +19,11 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning"
android:debuggable="true">
>
<service
android:name=".LorieService"
android:enabled="true"
android:exported="false"/>
<service
android:name=".LorieTestService"
android:enabled="true"
android:exported="true"
android:process="com.termux.x11.separated"/>
<activity android:name=".MainActivity"
android:theme="@style/NoActionBar"
android:launchMode="singleInstance"
Expand All @@ -50,8 +46,13 @@
android:supportsPictureInPicture="false"
android:resizeableActivity="true">
</activity>
<activity android:name=".TermuxX11StarterReceiver"
android:excludeFromRecents="true"
android:exported="true" />
<meta-data android:name="com.samsung.android.multidisplay.keep_process_alive" android:value="true"/>
<meta-data android:name="android.allow_multiple_resumed_activities" android:value="true" />
</application>

<queries>
<package android:name="com.termux" />
</queries>
</manifest>
12 changes: 0 additions & 12 deletions app/src/main/aidl/com/termux/x11/ITermuxService.aidl

This file was deleted.

Binary file added app/src/main/assets/X11.zip
Binary file not shown.
Loading