tos library / Main page

tos

tos (the tos framework library) is a small Python module that provides convenience helpers for applications running on top of TrashOS Reborn. It exposes a per-application data directory, a cross-platform terminal helper, a root-mode check, and a version string.

Note: tos is designed to be imported by apps located in the tosapps/ folder of a TrashOS installation. It can also be imported standalone from any Python 3 script.

Overview

MemberKindPurpose
tos.appdataobjectResolve per-app data directories under ./appdata/.
tos.termobjectCross-platform terminal helpers (clear screen, etc.).
tos.is_root()functionReturns whether the current shell is in root mode.
tos.versionstringLibrary version constant.

Quick example

import tos

# Get a writable folder for your app
data_dir = tos.appdata.path("mynotes")

# Clear the terminal
tos.term.cls()

# Detect root mode
if tos.is_root():
    print("Running as root")

print("tos version", tos.version)

Where to go next