Skip to content

How to Contribute

theofficialgman edited this page Jul 18, 2021 · 10 revisions

How do I write a script?

Usually the scripts as part of the megascript start off with other developer documentation at the repository of the game/application/program that you are trying to automate setting up.

Every script in this repo can be used as reference material for how to write to a file as root, how to prompt the user for input, and many more examples throughout the scripts

The available functions

get_system

This function saves the jetson_model and architecture variables for use within the scripts:

jetson_model contains one of: tegra-2, tegra-3, tegra-4, tegra-x1, tegra-x2, xavier or an empty string
refer to the box64.sh script for a good use of the jetson_model type to change cmake options when configuring box64

architecture contains the cpu type: aarch64, x86_64, i386, etc
refer to the edex-ui.sh script for a good example of architecture variable in action

userinput_func

This function prompts the user for input through a GUI (zenity) or CLI (dialog) interface.
Its easiest to explain through an example usecase so one is given below:

description="This is an example of how to get user input.\
\nYou can print to multiple lines as shown here.
\n\n The table below can contain list of desired options that are passed as the variable `output`"
table=("yes" "no" "maybe")
userinput_func "$description" "${table[@]}"
if [[ $output == "yes" ]]; then
  echo "You chose yes"
elif [[ $output == "no" ]]; then
  echo "You chose no"
elif [[ $output == "maybe" ]]; then
 echo "What do you mean maybe? "
fi
Clone this wiki locally