Skip to content

Swiss Army Knife For Android. Create and Run Linux Commands on Android in a single click.

License

Notifications You must be signed in to change notification settings

cryptrr/AutoPie

Repository files navigation

AutoPie

Create your own Commands and Run them on your Android without wasting time.

Lets you run Python scripts with or without included binaries on Android.

AutoPie is your own power tool-kit for android.

AutoPie extras config AutoPie extras config

Installation

  1. Build from source yourself or get the prebuilt APK from the releases section.
  2. Install the APK and accept Play Protect Dialogs if any.
  3. Wait for the Python Binaries to get installed.
  4. Grant necessary permissions.
  5. AutoPie will try to download an init binary & configuration archive and extract it into the AutoSec directory. If it fails, you can download the autosec.tar.xz file and extract to the AutoSec folder.
  6. Optional: Disable Battery Optimization for AutoPie.

Usage

  1. Open AutoPie App
  2. There are currently two types of commands. Share Sheet Commands, Folder Observer Commands and Cron Commands.
  3. Add your desired Commands in the AutoPie App by clicking on Add Button or Edit an already existing command.

Troubleshooting

  • Check that the AutoSec folder contains observers.json for Folder Observation Automation, shares.json for Share Sheet Configuration and cron.json for Cron Configuration. And a bin folder with the binaries like ffmpeg.

Command Format

PLACEHOLDER DESCRIPTION
${INPUT_FILE} Use it to pass input file path or url in the command
${INPUT_FILES} If multiple files are needed as input to the command
Example : magick combine two images
${FILENAME} Filename without path
${DIRECTORY} Parent Directory of file
${FILENAME_NO_EXT} Filename without path and extension
${FILE_EXT} File extension
${RAND} Random 4 digit number
${HOST} URL host (Only available if the input is a URL)

Example Commands

USE COMMAND
Ffmpeg Extract Audio from Video -i ${INPUT_FILE} -b:a 192K -vn ${INPUT_FILE}.mp3
ImageMagick combine horizontal ${INPUT_FILES} +append ${INPUT_FILE}-horiz-${RAND}.jpeg

This configuration enables you to automatically convert each screenshot you take into webp.

AutoPie file observer example command

Custom Defined Command Arguments for Customization.

With AutoPie, you can define custom arguments called (extras) for commands.

This will show a card where you can input details to customize the behaviour of the command.

For Example,

Defining extra items such as options for codecs etc will look like this.

AutoPie extras config AutoPie extras how to

Commands and Package Repository

A repository where users can search and add pre-made AutoPie command snippets and install packages is in the works.

How do I create binaries for AutoPie.

AutoPie binaries are just thin python wrappers around binaries like ffmpeg magick etc.

Using Shiv to package the binaries, dependencies and python files is strongly recommended.

This is an example for how to include the ffmpeg binaries and libraries in a single file with shiv.

A more detailed docs is in WIP.

import subprocess
import sys
import os
import shlex

script_dir = os.path.dirname(__file__)

# Set the path to the ImageMagick binary and library directories
bin_path = os.path.join(script_dir, 'usr', 'bin')
lib_path = os.path.join(script_dir, 'usr', 'lib')

# Update PATH environment variable
os.environ['PATH'] = bin_path + os.pathsep + os.environ['PATH']

# Update LD_LIBRARY_PATH environment variable
os.environ['LD_LIBRARY_PATH'] = lib_path + os.pathsep + os.environ.get('LD_LIBRARY_PATH', '')



def main():
    
    """Console script for ffmpeg wrapper"""

    input_command = sys.argv[1]

    commands_list = shlex.split(input_command)

    runner(commands_list)

def runner(commands_list: list[str]):

    try:

        commands_list= ["ffmpeg"] + commands_list

        print(f"shlex command list: {commands_list}")

        result = subprocess.run(commands_list)

        if result.returncode == 0:
            print(f"Successfully executed {commands_list}")
        else:
            print(f"Subprocess failed with exit code {result.returncode} : {commands_list}")
        
        sys.exit(result.returncode)
        
    except Exception as e:
        print(f"Unexpected error: {e}")
        sys.exit(e.returncode)


if __name__ == "__main__":
    main()

Build Instructions

You can build the app with prebuilt binaries by opening the project with Android Studio and then run build task.

If you want to build your own python and busybox binaries

  • Set Environment Variable ANDROID_NDK_ROOT to your Android NDK installation folder.
  • Run the ./build-all.sh script to build all dependencies and store them in the Assets folder.

Support

  • Supports only aarch64/arm-v8 as of now. It should run on most newer phones.

Why

  • Makes it easier to automate and run any task.
  • Termux will be constrained in the future by Android Platform limitations.
  • Needed to find an alternative method to Termux by including a whole Python installation in the APK itself that enables us to run scripts and binaries from anywhere on the storage.

Thanks To

Jared Drummler

About

Swiss Army Knife For Android. Create and Run Linux Commands on Android in a single click.

Resources

License

Stars

Watchers

Forks

Packages

No packages published