roturLink provides cross-platform system monitoring and control capabilities through both HTTP REST APIs and WebSocket connections. This document details the implementation differences between the Arch Linux (archLink.py) and macOS (macosLink.py) versions.
Both implementations follow the same architectural pattern:
Both platforms use an embedded configuration:
CONFIG = {
"allowed_modules": [
"system", "cpu", "memory", "disk", "network",
"bluetooth", "battery", "temperature"
],
"allowed_origins": [
"https://turbowarp.org", "https://origin.mistium.com",
"http://localhost:5001", "http://localhost:5002", "http://localhost:3000",
"http://127.0.0.1:5001", "http://127.0.0.1:5002", "http://127.0.0.1:3000"
]
}
Purpose: Provides basic system and hardware information
platform.system() == "Linux"bluetoothctl show commandplatform.system() == "Darwin"system_profiler SPBluetoothDataTypeplatform.mac_ver()[0]Common Data Returned:
{
"platform": {"system": "macOS/Arch Linux", "architecture": "arm64/x86_64"},
"cpu": {"cores": 8, "threads": 16},
"bluetooth": {"available": true, "backend": "bleak"},
"memory": {"total_gb": 16.0},
"hostname": "hostname"
}
Purpose: Real-time CPU usage monitoring
psutil.cpu_percent(interval=0.05)Data Returned:
{"cpu": {"percent": 25.4}}
Purpose: RAM usage statistics
Both Platforms
psutil.virtual_memory()Data Returned:
{
"memory": {
"total": 17179869184,
"used": 8589934592,
"percent": 50.0
}
}
Purpose: Storage usage information
Both Platforms
psutil.disk_usage("/")Data Returned:
{
"disk": {
"total": 1000000000000,
"used": 500000000000,
"percent": 50.0
}
}
Purpose: Network I/O statistics
Both Platforms
psutil.net_io_counters()Data Returned:
{
"network": {
"sent": 1234567890,
"received": 9876543210
}
}
Purpose: WiFi connection status and nearby network scanning
Arch Linux
gi.repository.NMdevice.request_scan_async()python-networkmanager, python-gobjectmacOS
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -Iairport -smax(0, min(100, (rssi + 100) * 2))Data Returned:
{
"wifi": {
"connected": true,
"ssid": "NetworkName",
"signal_strength": 85,
"scan": [
{"ssid": "Network1", "signal_strength": 90, "frequency": 2412, "connected": false},
{"ssid": "Network2", "signal_strength": 75, "frequency": 5180, "connected": false}
]
}
}
Purpose: Bluetooth device discovery and monitoring
Both Platforms
bleak (cross-platform Bluetooth Low Energy library)BleakScanner.discover(timeout=2.0)BLUETOOTH_DEVICES dictionaryData Returned:
{
"bluetooth": {
"devices": [
{"name": "Device Name", "address": "AA:BB:CC:DD:EE:FF", "rssi": -45, "last_seen": 1640995200}
],
"count": 1,
"timestamp": 1640995200
}
}
Purpose: Battery status and power information
Both Platforms
psutil.sensors_battery()Data Returned:
{
"battery": {
"percent": 85.5,
"plugged": true
}
}
Purpose: Display brightness monitoring and control
Arch Linux
brightnessctl get and brightnessctl maxbrightnessctl set {percentage}%brightnessctl -mbrightnessctl packagemacOS
brightness -l command (requires installation)brightness {decimal_value}brightness (install via brew install brightness)API Endpoints:
GET /brightness/get - WebSocket: brightness_getPOST /brightness/set/{percentage} - WebSocket: brightness_setPurpose: Audio volume monitoring and control
Arch Linux
pulsectlamixer commandspython-pulsectl, alsa-utilsmacOS
osascriptoutput volume of (get volume settings)set volume output volume {percentage}set volume output muted {true/false}API Endpoints:
GET /volume/get - WebSocket: volume_getPOST /volume/set/{percentage} - WebSocket: volume_setPOST /volume/mute - WebSocket: volume_mutePurpose: USB drive detection, mounting, and file system access
Arch Linux
pyudev for hardware enumerationudisksctl mount/unmount with sudo mount fallback/proc/mounts parsingpython-pyudev, udisks2macOS
/Volumes/ directory listingdiskutil mount/unmountdiskutil info for device detailsdiskutilSecurity: Path validation restricts access to mounted USB drives only
API Endpoints:
GET /usb/drives - List mounted drivesGET /usb/unmounted - List unmounted devicesPOST /usb/mount - Mount devicePOST /usb/remove - Safely unmount devicePurpose: File operations on USB drives
Both Platforms
os.listdir() with metadataSecurity: All operations restricted to validated USB drive paths
API Endpoints:
GET /fs/list/{path} - List directory contentsGET /fs/read/{path} - Read file contentPOST /fs/write/{path} - Write file contentPOST /fs/mkdir/{path} - Create directoryDELETE /fs/delete/{path} - Delete file/directoryPurpose: System temperature monitoring
psutil.sensors_temperatures() on Linux, powermetrics on macOS{
"cmd": "command_name",
"val": { /* command-specific data */ }
}
https://link.rotur.dev/allowed.jsonpacman package manager integrationpython-flask, python-flask-cors, python-psutil, python-requests, python-websockets, python-bleakpython-pulsectl, python-pyudev, python-networkmanager, python-gobjectbrightnessctl, bluetoothctl, amixer, udisksctlflask, flask-cors, psutil, requests, websockets, bleakbrightness (via Homebrew)diskutil, osascript, airport, system_profilerCONFIG["allowed_modules"]run_command() wrapper for system calls