Skip to main content

πŸ“ Get Values Tools

Utilities for extracting information.


import_config​

Supports: _addon _zip

Converts prop lines (a = b) from a file into variables ($a).

ArgumentDescription
FILEProp file
# example.prop: name=Some name, current_version=v1.1.0, i_d_k=S o m e t h i n g
import_config "$TMP/example.prop"
ui_print "$name" # Prints "Some name"
ui_print "$current_version" # Prints "v1.1.0"
ui_print "$i_d_k" # Prints "S o m e t h i n g"
note

Props with special characters won’t become variables.


get_file_prop​

Extracts a property from one or more prop files.

ArgumentDescription
FILEProp file(s)
PROPProperty to extract
get_file_prop /system/build.prop "ro.build.display.id"

# Multiple files
get_file_prop /system/build.prop /vendor/build.prop /system_ext/build.prop "ro.build.display.id"

# Store result
myid=$(get_file_prop /system/build.prop "ro.build.display.id")
note

The search will stop at the first match, always returning a single value.


map_file_props​

Maps multiple properties from one or more files into an array.

FlagDescription
-var (-v)Name of the array to store results.
-files (-f)Files to search.
-props (-p)Properties to find.

Example:

map_file_props -v my_array -f "/sdcard/file1.prop" "/sdcard/file2.prop" -p "ro.build.version" "ro.product.model"

ui_print "${my_array[0]}" # ro.build.version value
ui_print "${my_array[1]}" # ro.product.model value

note
  • The search will stop when at least one match for each property has been found. That is, only the value of the first match for each property is considered.
  • An ordered array is always guaranteed, even if one of the properties was not found. Its corresponding space will be filled with an empty value.

getdefault​

Extracts setdefault values from a file (no multi-line support).

ArgumentDescription
FILEFile with setdefault lines
KEYKey to extract
# something.txt: setdefault ole "a b c", setdefault okay "d e f", setdefault test "s o m e t h i n g"
getdefault "$TMP/something.txt" okay # Returns "d e f"
getdefault "$TMP/something.txt" test # Returns "s o m e t h i n g"

# Store result
my_var=$(getdefault "$TMP/something.txt" okay)

get_array​

Gets a full value from an array matching a pattern.

ArgumentDescription
PATTERNPattern to match
ARRAYArray to search
test=("First array" "Other array" "A B")
get_array "Other" "${test[@]}" # Returns "Other array"

# Store result
content=$(get_array "Other" "${test[@]}")

get_size_ext4​

Gets the size in bytes of an ext4 partition or RAW .img.

ArgumentDescription
PATHPartition or .img file
get_size_ext4 "$(find_block system)"

# From file
get_size_ext4 "/sdcard/vendor.img"

# Store result
size=$(get_size_ext4 "$(find_block system)")

fullpath​

Gets the full path of a file, folder, or symlink (returns literal symlink paths).

ArgumentDescription
PATHFile, folder, or symlink
fullpath "folder/file"

# Store result
complete_path=$(fullpath "folder/file")