Skip to content

Instantly share code, notes, and snippets.

@gsmitheidw
Created November 8, 2019 16:43
Show Gist options
  • Save gsmitheidw/56541d3117e10cecc1cb9b0ebde78656 to your computer and use it in GitHub Desktop.
Save gsmitheidw/56541d3117e10cecc1cb9b0ebde78656 to your computer and use it in GitHub Desktop.
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
Copy link

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

@Ricc4rdo0107
Copy link

Ricc4rdo0107 commented Dec 26, 2022

@khansaad1275 termux-dialog radio -v "case 1, case 2, case 3", you can also try using termux-dialog -l to list all available options

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