Skip to content

Latest commit

 

History

History
102 lines (68 loc) · 2.53 KB

README.md

File metadata and controls

102 lines (68 loc) · 2.53 KB

TaskerPy

TaskerPy is a tool for creating Android automations using Python, simplifying the integration and control of tasks via Tasker.

Requirements

Quick Start

Install directly from GitHub:

pip install git+https://github.com/brunodavi/tasker.py

Usage Example

Here’s a simple demonstration of how to create an automation with TaskerPy from Android:

from tasker.py import TaskerPy, Task
from tasker.actions.alert import Flash as Toast, Beep

app = TaskerPy()

# Displays a message and plays three beeps
@app.add_task(name='Show Popup')
def hello_world():
    yield Toast('Hello, World', long=True)
    yield Beep(frequency=8_000, duration=100)
    yield Beep(frequency=9_000, duration=100)
    yield Beep(frequency=10_000, duration=100)

# Imports the task and executes it
hello_world.play()
hello_world.export()  # Exports as XML to /sdcard/Tasker/tasks/Show_Popup.tsk.xml

Contributing

Contributions are welcome! Check the pending tasks on Projects.

Setting Up the Environment

We use PDM as the package manager. To set up the environment:

# Install dependencies
pdm install

# Activate the virtual environment
eval $(pdm venv activate)

# On Windows (PowerShell)
Invoke-Expression (pdm venv activate)

Requirement to lxml

Need libxml2 and libxslt

Available Scripts

The scripts defined in the pyproject.toml include:

  • test: To run tests.
  • docs: To generate documentation.
  • lint: To check code quality.
  • format: To format the code.

Example

# Run tests
pdm test

# Run tests ignoring Tasker actions
pdm test -k 'not action'

Connecting to Android

If the tasker.py project is already imported and running in Tasker, it should work on your phone by default. The default IP is localhost.

To run outside the phone, configure the .env file with your Android device’s IP:

TASKER_PY_ADDRESS=192.168.1.25

Notes

After importing the project in Tasker, click "Save" (✓), then tap the three dots to exit the editor.