termux / termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.
https://f-droid.org/en/packages/com.termux
Other
34.3k stars 3.6k forks source link

launcher mode support? #206

Open thewisenerd opened 7 years ago

thewisenerd commented 7 years ago

is it possible to have termux as a "launcher" screen?

this angle has been looked at by TUI-ConsoleLauncher ( https://github.com/Andre1299/TUI-ConsoleLauncher ), and I'd think that it would be nice to have an "optional" launcher mode.

a couple of user scripts using the Termux:API add-on and auto complete (volup + T) will make a good launcher.

as for the "launching" apps part, can be either done as a addon extension to Termux:API or cough su am start com.package/.Activity cough some userscripts.

xelxebar commented 6 years ago

As a T-UI user myself, I've been mulling over this idea for a while.

Turning Termux into a launcher, it turns out, is just a matter of adding a line to the manifest:

diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index aacc244..35cc0d4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -84,6 +84,7 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.IOT_LAUNCHER"/>
+                <category android:name="android.intent.category.HOME"/>
                 <category android:name="android.intent.category.DEFAULT"/>
             </intent-filter>
         </activity-alias>

So the actual work would be the "activity launching" stuff. Evidently, we can launch activities without root by passing the --user 0 flag to am start: e.g.

$ am start -n org.fdroid.fdroid/.FDroid --user 0

This works pretty well, and In theory we should be able to filter through the list of activities with

$ pm list packages

However, I'm only able to successfully do that via adb. From Termux, it's failing with android.os.DeadObjectException for some reason.

Anyway, we could probably make all this usable with a shell script or two and some bash completion functions.

thewisenerd commented 6 years ago

@xelxebar hi, and thanks for trying this out

pm list packages is crashing because of a selinux denial.

09-10 06:09:12.956  5209  5209 I main    : type=1400 audit(0.0:78): avc: denied { read write } for path="/dev/pts/0" dev="devpts" ino=3 scontext=u:r:system_server:s0 tcontext=u:object_r:untrusted_app_devpts:s0:c512,c768 tclass=chr_file permissive=1

i set my selinux to permissive and it works :smile:

need to figure out a way to fix this :crossed_fingers:

thewisenerd commented 6 years ago

@xelxebar i modified termux to handle a "apps-cache" intent[0] which lists all apps into $HOME/.apps which looks something like this;

FM Radio|com.android.fmradio/.FmMainActivity|com.android.fmradio|true
Camera|org.cyanogenmod.snap/com.android.camera.CameraLauncher|org.cyanogenmod.snap|true
Telegram|org.telegram.messenger/org.telegram.ui.LaunchActivity|org.telegram.messenger|false

coupled with a bash script[1], i can now launch apps :)

[0] https://github.com/thewisenerd/termux-app/commit/b877a81b999179af2d702b8929b6d20e29dde054 [1] https://github.com/thewisenerd/dotfiles/blob/droid/bin/zx

xelxebar commented 6 years ago

@thewisenerd This is an excellent solution :) Thanks!

ebflhippie commented 6 years ago

I am trying to create a run prompt for my device using termux, termux widget and or possibly automate... I am relitively new to "programming/scripting..", and still trying to get a feel for it all. I was wondering if the first file is a modified version of termux apk or a patch? Any resources i could read to helpme impliment it? or any further explaination on how these programs work. I do understand using the am command and can launch apps from termux... its just the rest, you know the hard stuff i need to figure out or just decipher from whats already been done thank you.

amsitlab commented 6 years ago

Without hacking termux apps , just calling termux activity https://github.com/amsitlab/termuxlauncher

Lavoista commented 5 years ago

Hi there @amsitlab , i just tried this, it works OK, thank you!

testedOn:

OS: Android 8.0.0 aarch64 Host: HUAWEI RNE-L03 Kernel: 4.4.23+ Uptime: secs Packages: 448 (dpkg), 1 (pkg) Shell: bash 4.4.23 Terminal: /dev/pts/1 CPU: (8) @ 1.709GHz Memory: 2247MiB / 3788MiB

me-nkr commented 4 years ago

@thewisenerd This is an excellent solution :) Thanks!

@xelxebar i modified termux to handle a "apps-cache" intent[0] which lists all apps into $HOME/.apps which looks something like this;

FM Radio|com.android.fmradio/.FmMainActivity|com.android.fmradio|true
Camera|org.cyanogenmod.snap/com.android.camera.CameraLauncher|org.cyanogenmod.snap|true
Telegram|org.telegram.messenger/org.telegram.ui.LaunchActivity|org.telegram.messenger|false

coupled with a bash script[1], i can now launch apps :)

[0] thewisenerd@b877a81 [1] https://github.com/thewisenerd/dotfiles/blob/droid/bin/zx

Hi man l am looking for a way to launch an app with termux and I'm a beginner. I think your script mentioned in this can help me with that. But I'm confused. So could you please tell me how to use it ? Thanks in advance

Etzio-TUI commented 3 years ago

I tried adding tmux as a launcher. Someone posted how to do it. I just can't figure out how to use it as a launcher. He said to use bash... Wasn't very descriptive as I'm new to all this. When I got done running all the scripts tui popped up and says "default. Launcher". I don't know what that means or what I did in termux for Tui to do that.

Decapitater commented 2 years ago

Any official developments ?

twaik commented 8 months ago

Technically it is possible to add activity-alias to TermuxActivity like it is done in HomeActivity alias for IoT devices. But normally disabled (to not appear as launcher out-of-the-box) with a possibility to enable/disable it from Termux settings (like it is done for FileShareReceiverActivity and FileViewReceiverActivity). In this case we will not break current behaviour.