# Developer Utilities

# Introduction

GearLock brings a wide range of prebuild linux utils that you may find in a well-known linux distro nowadays. You get things like bash, python and so on! There are also some additional build-in functions which can ease your scripting work. Lets start with the basics. (bash specific)

# geco

You can use geco to print anything on the terminal with color/underline/blink option.

  • Normal output Example:
geco "Hello, you printed this message with geco"

Note: You must quote " " your message if it contains any special characters or spaces.

# geco color output

  • Syntax
geco "${COLOR-CODE}Some text${RC}"
  • Example:
geco "${YELLOW}Hello${RC}, you printed this message with geco"

# Color codes for geco

Basic Bold Underline
$ $ $
$ $ $
$ $ $
$ $ $
$ $ $
$ $
$ $

Note: Here ${RC} is used to reset the color to normal.
Otherwise your whole terminal screen would get messed up!

# geco extensions

# gecca

gecca can print the output from a text file into the middle of your terminal screen.


gecca yo.txt


                                | |__   ___ _   _ 
                                | '_ \ / _ \ | | |
                                | | | |  __/ |_| |
                                |_| |_|\___|\__, |

# gecpc

gecpc can print a line with full width of your screen


gecpc "In the middle" "+"


+++++++++++++++++++++++++++++++++ In the middle +++++++++++++++++++++++++++++++++

# Advanced geco usage

If linux is your daily driver then you should be obviously fimiliar with the things that I'm about to show you.

Geco always prints with a partly hidden \n newline character. It might be a bit hard to notice it but it actually works like that.

For example:

geco "Hello, world!"


Hello, world!

For a live practice, try this and see for yourself:

clear; geco "Hello, world!"; sleep 10

#### Excluding newline from geco --------------------------------

If you want to do something trickiy then you can exclude the newline.

For example:

geco "Hello, world!\c"


Hello, world!

To make the concept clear with a more practical example:

geco "This file does not exist \c"; rm /baloo

Which gives:

This file does not exist rm: cannot remove '/baloo': No such file or directory

While if you do (without \c character at the end of you message)

geco "This file does not exist "; rm /baloo


This file does not exist 
rm: cannot remove '/baloo': No such file or directory

Notice the \c, it's used at the end of your message to avoid making a newline \n character.

#### Including extra newlines --------------------------

Just in the way you exclude the hidden \n newline with \c, it's just doing the opposite.
Which is, you include it!


geco "Here I am\n"


Here I am

Notice that it has two extra newlines instead of one. (1 by default + 1 because of an extra /n char)

You can include as many newlines you like.

geco "Here I am\n\n\n"
Here I am

geco alternatives: echo printf

# figlet

figlet can print real-time ascii art from text. If you've used this on a typical linux distro then you might already know what this is.

  • With default font: figlet <text>

Example: figlet Hey

                                | |__   ___ _   _ 
                                | '_ \ / _ \ | | |
                                | | | |  __/ |_| |
                                |_| |_|\___|\__, |
  • With a custom font: figlet -f <font-name> <text>

Example: figlet -f graffiti GearLock

              ________                    .____                  __    
             /  _____/  ____ _____ _______|    |    ____   ____ |  | __
            /   \  ____/ __ \\__  \\_  __ \    |   /  _ \_/ ___\|  |/ /
            \    \_\  \  ___/ / __ \|  | \/    |__(  <_> )  \___|    < 
             \______  /\___  >____  /__|  |_______ \____/ \___  >__|_ \
                    \/     \/     \/              \/          \/     \/

Available fonts: banner big block bubble digital graffiti hex ivrit lean mini mnemonic script shadow slant small smscript smshadow smslant standard (default) term

# nout

nout comes with GearLock which can make it easy for you to silence almost any command.

For example, lets say that you want to delete a file but you don't want to have any error output for that if any error occours.

So, if you do something like:

rm /system/wackadua

And then rm gives the output:

rm: cannot remove '/system/wackadua': No such file or directory

Which if you want to silent then you can:

nout rm /system/wackadua


As you can see, no output came out but the command was surely done. Although you should always test out each of the command that you silence to be sure that it actually ran instead of doing nothing.

# gclone

For doing the copy-paste job easily over file & folders you get to use gclone and you must use it! gclone is initially rsync and it's just here to make it a bit more quicker to do the thing while showing a human friendly progress bar.

  • With progress indicator gclone /source /terget

Example: gclone /system/priv-app/GmsCore /sdcard/Downloads

  • Without progress indicator gclone -q /source /terget

Example: gclone -q /system/build.prop /data/adb

You can also use rsync for advanced use since gearlock brings pretty much all the native linux utils that you may find in a well-known linux distro nowadays.

gclone alternatives: cp rsync cat mv

# gkillapp

gkillapp can easily stop a running android app with the package-id.

  • Syntax

gkillapp <package-id>

  • Example
gkillapp "com.google.vending"

Note: If the app is not running then gkillapp will print an error message.

# gslr

GearLock search line and replace (gslr) can scan a readable file for a word or line and replace the result with the specified text.

Usage: gslr <terget-file> <text-to-search> <the-text-to-replace-result>


gslr /system/foo "Hello world!" "Yo, you got me!"

Note: Gslr only takes the first line which was found as the result and will return an error if not found.

gslr alternatives: sed awk

# gearprop

gearprop can help when you need to modify multiple system props.
It also got the capability to force overwrite any kind of property. (Bypassing setprop limitations) There are two ways you can acheive this, which are:

  • Through a variable
  • From a readable text file

# Through a variable

Define your props inside a var in <prop> <value> format.
Which obviously is supposed to be called from a script.

An example: (from gearprop --help)

# Define your props inside a var in <prop> <value> format
dalvik.vm.heapmaxfree 8m
net.bt.name Android
dalvik.vm.stack-trace-file /data/anr/traces.txt

# Now call the var over gearprop with quotes
gearprop "$my_var"

Note: You must always use quotes " " while calling your variable.

# From a readable text file

This is also pretty simple and straightforward.
Just like the variable method, define your props in <prop> <value> format in your text file.

Let's assume you have a text file named myprops.txt

Then you can do:

gearprop myprops.txt

Extra notes: You can define your props in <prop>=<value> format also but thats deprecieated. Also, you can specify multiple variable or files together. GearProp initially passess all the processed data to gearprop-helper and it does the rest.

gearprop alternative: setprop

# gearhost

GearHost can be used to reroute static ip's with the same implementation as in /system/etc/hosts but dynamically.

The usage is same as gearprop.

Try gearhost --help in the command line to learn more.

# ckdirex

ckdirex checks whether if the specified folder exist, if not then it makes that folder with an optional permission.

  • Syntax
ckdirex <folder-path> <optional-permission>
  • Example (with optional-permission)
ckdirex /system/new 755
  • Example (without specifying any permission)
ckdirex /system/new

# garca

garc is basically a fork of 7z. You can use it to extract almost any archive.

Note: garc comes with additional zstd support.

  • Basic Syntax
garca x -o<output-location> -p<optional-password> <acheive-name>
  • Example
garca x -o"/data/media" /system/my-archive.zip
  • All functions
Usage: garca <command> <switches> <archive_name>

  a : Add files to archive
  b : Benchmark
  d : Delete files from archive
  e : Extract files from archive (without using directory names)
  h : Calculate hash values for files
  i : Show information about supported formats
  l : List contents of archive
  rn : Rename files in archive
  t : Test integrity of archive
  u : Update files to archive
  x : eXtract files with full paths

  -- : Stop switches parsing
  -ai[r[-|0]]{@listfile|!wildcard} : Include archives
  -ax[r[-|0]]{@listfile|!wildcard} : eXclude archives
  -ao{a|s|t|u} : set Overwrite mode
  -an : disable archive_name field
  -bb[0-3] : set output log level
  -bd : disable progress indicator
  -bs{o|e|p}{0|1|2} : set output stream for output/error/progress line
  -bt : show execution time statistics
  -i[r[-|0]]{@listfile|!wildcard} : Include filenames
  -m{Parameters} : set compression Method
    -mmt[N] : set number of CPU threads
  -o{Directory} : set Output directory
  -p{Password} : set Password
  -r[-|0] : Recurse subdirectories
  -sa{a|e|s} : set Archive name mode
  -scc{UTF-8|WIN|DOS} : set charset for for console input/output
  -scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files
  -scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands
  -sdel : delete files after compression
  -seml[.] : send archive by email
  -sfx[{name}] : Create SFX archive
  -si[{name}] : read data from stdin
  -slp : set Large Pages mode
  -slt : show technical information for l (List) command
  -snh : store hard links as links
  -snl : store symbolic links as links
  -sni : store NT security information
  -sns[-] : store NTFS alternate streams
  -so : write data to stdout
  -spd : disable wildcard matching for file names
  -spe : eliminate duplication of root folder for extract command
  -spf : use fully qualified file paths
  -ssc[-] : set sensitive case mode
  -ssw : compress shared files
  -stl : set archive timestamp from the most recently modified file
  -stm{HexMask} : set CPU thread affinity mask (hexadecimal number)
  -stx{Type} : exclude archive type
  -t{Type} : Set type of archive
  -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options
  -v{Size}[b|k|m|g] : Create volumes
  -w[{path}] : assign Work directory. Empty path means a temporary directory
  -x[r[-|0]]{@listfile|!wildcard} : eXclude filenames
  -y : assume Yes on all queries

garc alternatives: 7z tar gzip bzip2 cpio zcat zip

# get_base_dir

When you call the function get_base_dir from a script,
it return's the base directory path from where that script is being executed in $BD variable.

Hint: This function is implemented on the install.sh of both core & prebuild-kernel package.

# get_net_stat

When you call the function get_net_stat from a script

  • While the host system is connected with internet

NET_CONN=yes and return code is 0

  • While the host system is not connected with internet

NET_CONN=no and return code is 1

Example script for practice:

# Call get_net_stat function

# Now perform action on condition (a simple example, can be done in many ways)
if [ "$NET_CONN" = "yes" ]; then

    geco "Yay, you're connected with the internet ...!"
    # Do something

    geco "Sorry, I can't work without internet connection :("
    exit 1


# check_compat

If you want to check whether the host user is running a GearLock version which might not be compatible with your package/extension then you can call check_compat function.

Usage: check_compat <minimum-terget-version>


check_compat 6.4

Let's say the user is running GearLock 6.1, thus it will return 1 as the return-code and an additional variable as COMPAT=no.

While if the user is running GearLock 6.1 or higher version it will return 0 and COMPAT=yes

# linux utils

Take a look at /gearlock/bin to know about all the linux utils which are available for use!

ls /gearlock/bin

['@                        [email protected]          [email protected]        gearlock-cli*      [email protected]        [email protected]             partx*              [email protected]              [email protected]            [email protected]
'[['@                       chrt*            [email protected]        gearlock-post*     [email protected]        mcookie*            [email protected]             [email protected]                  [email protected]          [email protected]
 [email protected]                      [email protected]            [email protected]          gearprop*          [email protected]       [email protected]             [email protected]              [email protected]               tabs*            [email protected]
 2to3-3.8*                  ckdirex*         [email protected]        gearprop-helper*   [email protected]       [email protected]             [email protected]              [email protected]               [email protected]             [email protected]
 7z*                        [email protected]           fallocate*     gearrec*           [email protected]        [email protected]                patchelf*           rmt*                 [email protected]            [email protected]
 [email protected]                       clear*           [email protected]         gecca*             [email protected]      mkbootimg*          [email protected]            [email protected]               tar*             [email protected]
 [email protected]                      [email protected]             [email protected]         geco*              isosize*       mk_cmds*            pcre2-config*       [email protected]               taskset*         [email protected]
 addpart*                   col*             fetch*         gecpc*             [email protected]          [email protected]              pcre2grep*          rsync*               [email protected]              [email protected]
 add-trusted-certificate*   colcrt*          fetch.in*      [email protected]           [email protected]          [email protected]            pcre2test*          rtcwake*             [email protected]          [email protected]
 [email protected]                   colrm*           [email protected]     getopt*            [email protected]       mke2fs*             pcre-config*        [email protected]              [email protected]             [email protected]
 [email protected]                        column*          fgrep*         gfe*               [email protected]      [email protected]             pcregrep*           [email protected]           [email protected]          wdctl*
 [email protected]                      [email protected]            figlet*        gink*              ldattach*      mkfs*               pcretest*           [email protected]               [email protected]         wget*
 [email protected]                       compile_et*      figlist*       gkillapp*          less*          mkfs.bfs*           [email protected]              [email protected]            [email protected]            [email protected]
 [email protected]                    coreutils*       file*          grcat*             lessecho*      mkfs.cramfs*        [email protected]              [email protected]                  [email protected]            whereis*
 [email protected]                     [email protected]           filefrag*      grep*              lesskey*       [email protected]          [email protected]               script*              [email protected]           [email protected]
 [email protected]                       [email protected]              fincore*       [email protected]            [email protected]          [email protected]          [email protected]      scriptlive*          tic*             [email protected]
 [email protected]                       cpio*            find*          gsdir*             [email protected]       [email protected]          [email protected]         scriptreplay*        [email protected]            [email protected]
 axel*                      [email protected]           findfs*        gslr*              [email protected]       mkfs.minix*         [email protected]              sed*                 [email protected]         [email protected]
 [email protected]                     c_rehash*        fixfs*         gstatus*           [email protected]            [email protected]          [email protected]               [email protected]            toe*             wipefs*
 badblocks*                 [email protected]           fixscreen*     gsudo*             [email protected]      mklost+found*       [email protected]         [email protected]                 [email protected]             xargs*
 [email protected]                    [email protected]         flock*         gunzip*            locate*        [email protected]              [email protected]                 setarch*             [email protected]           [email protected]
 [email protected]                    [email protected]          [email protected]           gxpm*              [email protected]        [email protected]           [email protected]           [email protected]             toybox*          xz*
 [email protected]                  ctrlaltdel*      [email protected]          gzexe*             [email protected]       mkrecovery*         [email protected]             setsid*              tput*            [email protected]
 [email protected]                    curl*            frcode*        gzip*              logsave*       mkswap*             prlimit*            setterm*             [email protected]              [email protected]
 bash*                      curl-config*     [email protected]          [email protected]              look*          [email protected]             [email protected]                 [email protected]           [email protected]      xzdec*
 bashbug*                   [email protected]             fsck*          hardlink*          losetup*       [email protected]            [email protected]              [email protected]                  tree*            xzdiff*
 [email protected]                  [email protected]            fsck.cramfs*   [email protected]                [email protected]            moon-buggy*         [email protected]             [email protected]             [email protected]            [email protected]
 [email protected]                        [email protected]              [email protected]     [email protected]              lsattr*        more*               [email protected]                [email protected]           [email protected]        [email protected]
 blkdiscard*                [email protected]              [email protected]     [email protected]              lscpu*         [email protected]              pv*                 [email protected]           tset*            xzgrep*
 blkid*                     debugfs*         [email protected]     hexdump*           lsipc*         [email protected]         pwcat*              [email protected]           [email protected]           xzless*
 blkzone*                   delpart*         fsck.minix*    [email protected]           [email protected]         [email protected]             [email protected]                [email protected]             [email protected]             xzmore*
 blockdev*                  demandoc*        fsfreeze*      [email protected]          lsof*          [email protected]                 [email protected]               [email protected]           ttyecho*         [email protected]
 [email protected]                     [email protected]          [email protected]        [email protected]             [email protected]         namei*              [email protected]              showfigfonts*        [email protected]         zcat*
 [email protected]                   dialog*          [email protected]        hwclock*           [email protected]        nano*               [email protected]             [email protected]               [email protected]          zcmp*
 busybox*                   [email protected]            [email protected]         [email protected]         [email protected]         [email protected]                 pydoc3.8*           [email protected]                tune2fs*         zdiff*
 [email protected]                     [email protected]             [email protected]          [email protected]           [email protected]         ncursesw6-config*   [email protected]             [email protected]               [email protected]          zegrep*
 [email protected]                     [email protected]       [email protected]        [email protected]            [email protected]         neofetch*           [email protected]            [email protected]             ul*              zfgrep*
 bzdiff*                    [email protected]         [email protected]        [email protected]            [email protected]        [email protected]             python3.8*          [email protected]                [email protected]          zforce*
 bzgrep*                    dmesg*           funzip*        [email protected]              [email protected]       [email protected]            python3.8-config*   soelim*              [email protected]          zgrep*
 bzip2*                     [email protected]   [email protected]         iconv*             [email protected]       [email protected]               [email protected]     [email protected]           [email protected]           zip*
 bzip2recover*              [email protected]        [email protected]             [email protected]                [email protected]        ninvaders*          [email protected]      [email protected]                [email protected]         zipcloak*
 [email protected]                    [email protected]              garc*          [email protected]              lzip*          [email protected]                 [email protected]              [email protected]               uncompress*      zipgrep*
 bzmore*                    dumpe2fs*        [email protected]         [email protected]             [email protected]        [email protected]             [email protected]          sqlite3*             [email protected]        [email protected]
 cal*                       e2freefrag*      gawk*          idle3.8*           [email protected]          [email protected]              [email protected]           [email protected]   [email protected]            zipnote*
 [email protected]                 e2fsck*          gawk-5.0.1*    [email protected]          lzmadec*       nout*               readprofile*        [email protected]                [email protected]        zipsplit*
 [email protected]                       e2image*         [email protected]         infocmp*           lzmainfo*      [email protected]              [email protected]           [email protected]              [email protected]          zless*
 [email protected]                      [email protected]         gclone*        [email protected]         [email protected]        nsenter*            [email protected]             [email protected]             [email protected]          zmore*
 chattr*                    [email protected]     gdbm_dump*     [email protected]          [email protected]          nsnake*             [email protected]          [email protected]                [email protected]          znew*
 [email protected]                     e2scrub*         gdbm_load*     [email protected]            [email protected]       [email protected]             remount_android*    sudo*                unpackbootimg*   zramctl*
 chcpu*                     e2scrub_all*     gdbmtool*      [email protected]           make_ext4fs*   [email protected]                 rename*             [email protected]                 unshare*         zstd*
 [email protected]                     e2undo*          gdload*        ionice*            [email protected]      [email protected]              renice*             [email protected]                  [email protected]            [email protected]
 chkfont*                   e4crypt*         gearboot*      [email protected]          [email protected]    openssl*            [email protected]              [email protected]              unzip*           zstdgrep*
 [email protected]                     [email protected]            geardump*      [email protected]            [email protected]           [email protected]             [email protected]             swaplabel*           unzipsfx*        zstdless*
 choom*                     [email protected]              gearhost*      [email protected]             mandoc*        pacman*             resize2fs*          [email protected]             [email protected]          [email protected]
 [email protected]                     egrep*           gearinit*      [email protected]                mc*            pacmanedit*         resizepart*         [email protected]              updatedb*
 [email protected]                     [email protected]             gearlock*      [email protected]            [email protected]        parted*             rev*                [email protected]         [email protected]

Protip: Run bash in terminal and feel the real power ;) Say goodbye to sh !