termux-api
termux-api copied to clipboard
Feature request: List and launch apps
Currently, certain apps can be opened by opening a URL (e.g. open gemini://
or open mailto:
). Also apps can be "opened" by sharing a file to them.
Is there a generic way for termux to launch apps outright?
It also would be nice to be able to list apps (to make an interactive terminal application with acts as an app launcher).
I'd looked into this several months ago and have a few snippets lying around.
You can launch an activity with am start --user 0 "$x" &>/dev/null
, and you can get the list of activities you can use in place of $x
with
adb shell pm list packages | cut -d: -f2 | \
while read -r pkg; do
adb shell "cmd package resolve-activity --brief $pkg | tail -n1" </dev/null | grep '/'
done | sort
example: am start --user 0 org.fdroid.fdroid/.views.main.MainActivity &>/dev/null
Very hackish, but it worked perfectly last time I tried. You might want to look into this and improve it or, perhaps, work on a cleaner integration with termux.
edited to add: more (and better) ideas here