Skip to content

sgade/swift-desktopia

Repository files navigation

🖥️ swift-desktopia

Control your Desktopia Pro X from Swift.

🚀 Getting Started

Add swift-desktopia as a dependency to your Package.swift:

let package = Package(
    // name, platforms, products, etc.
    dependencies: [
        // other dependencies
        .package(url: "https://github.com/sgade/swift-desktopia", from: "1.0.0"),
    ],
    targets: [
        .executableTarget(
            name: "<your target>",
            dependencies: [
                // other dependencies
                .product(name: "DesktopiaProX", package: "swift-desktopia"),
            ]
        ),
        // other targets
    ]
)

🎯 Connecting to the desk

Connect your device to the desk controller via the USB connection, and then find the device name for that connection. Since it is a serial connection, you will need to find the corresponding device on your file system.

On macOS, these devices are usually called something like /dev/cu.usbserial-X, where X is a number.

With that device name, you can create a connection to the desk:

import DesktopiaProX

let desk = Desk(port: "/dev/cu.usbserial-123", keepAlive: true)
try await desk.connect()

The connection to the desk is in both ways, so you can send commands and the desk can send commands on its own.

🤓 Reading commands from the desk

You can get a stream of commands to read:

Task {
    let stream = try await desk.readCommands()

    for await command in stream {
        // interpret command...
    }
}

✨ Sending commands to the desk

To send commands to the desk, all you need to do is:

try await desk.send(command: .showStatus)

📜 The Desktopia Pro X protocol

The protocol has been reverse engineered from the official app (beta). Contributions and corrections are welcome.

License

See LICENSE.

About

Control your Desktopia Pro X from Swift

Topics

Resources

License

Stars

Watchers

Forks

Contributors