Skip to content

Instantly share code, notes, and snippets.

Getting started with Termux and termux-dialog

Put the output from a dialog box into a bash variable:

termux-dialog outputs data in json format so we need to parse that. One way is to use jq which needs to be installed: apt install jq -y

Then because we're going to pipe the output into jq we'll need to enclose everything in double quotes before assiging to a variable. This is is a good example:

myvariable="$(termux-dialog -t "Please enter some text" | jq '.text' -r)"

To test this has worked:

echo "$myvariable"

And you should see what you had entered has been assigned to "myvariable"

@khansaad1275

Grate ,it's working but can you please tell us how we can use checkbox and radio buttons?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment