{"id":16864938,"url":"https://github.com/nathanfallet/streamdeck-kotlin-sdk","last_synced_at":"2025-04-11T09:44:39.901Z","repository":{"id":230615182,"uuid":"779773691","full_name":"nathanfallet/streamdeck-kotlin-sdk","owner":"nathanfallet","description":"A Kotlin SDK to create Stream Deck plugins.","archived":false,"fork":false,"pushed_at":"2024-06-23T18:20:18.000Z","size":126,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T06:41:38.187Z","etag":null,"topics":["gradle","kotlin","streamdeck","streamdeck-sdk","streamdecksdk"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathanfallet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["nathanfallet"]}},"created_at":"2024-03-30T18:43:25.000Z","updated_at":"2025-03-20T11:32:58.000Z","dependencies_parsed_at":"2024-04-10T00:33:46.336Z","dependency_job_id":"8c2dd95c-a4eb-4ce0-9dfa-e8eae4313386","html_url":"https://github.com/nathanfallet/streamdeck-kotlin-sdk","commit_stats":null,"previous_names":["nathanfallet/streamdeck-kotlin-sdk"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanfallet%2Fstreamdeck-kotlin-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanfallet%2Fstreamdeck-kotlin-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanfallet%2Fstreamdeck-kotlin-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanfallet%2Fstreamdeck-kotlin-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathanfallet","download_url":"https://codeload.github.com/nathanfallet/streamdeck-kotlin-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248369364,"owners_count":21092570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gradle","kotlin","streamdeck","streamdeck-sdk","streamdecksdk"],"created_at":"2024-10-13T14:44:32.568Z","updated_at":"2025-04-11T09:44:39.856Z","avatar_url":"https://github.com/nathanfallet.png","language":"Kotlin","funding_links":["https://github.com/sponsors/nathanfallet"],"categories":[],"sub_categories":[],"readme":"# streamdeck-kotlin-sdk\n\n[![License](https://img.shields.io/github/license/nathanfallet/streamdeck-kotlin-sdk)](LICENSE)\n[![Issues](https://img.shields.io/github/issues/nathanfallet/streamdeck-kotlin-sdk)]()\n[![Pull Requests](https://img.shields.io/github/issues-pr/nathanfallet/streamdeck-kotlin-sdk)]()\n[![Code Size](https://img.shields.io/github/languages/code-size/nathanfallet/streamdeck-kotlin-sdk)]()\n[![codecov](https://codecov.io/gh/nathanfallet/streamdeck-kotlin-sdk/graph/badge.svg?token=iIM9xwE4QT)](https://codecov.io/gh/nathanfallet/streamdeck-kotlin-sdk)\n\nA Kotlin SDK to create Stream Deck plugins.\n\n## Install the SDK and the Gradle plugin\n\nAdd the gradle plugin and the dependency to your `build.gradle(.kts)`:\n\n```kotlin\nplugins {\n    id(\"me.nathanfallet.streamdeck\") version \"1.2.0\"\n}\n\ndependencies {\n    implementation(\"me.nathanfallet.streamdeck:streamdeck-kotlin-sdk:1.2.0\")\n}\n```\n\n## Usage\n\n### Create a plugin\n\nCreate a plugin is really simple, you just need to extend the `Plugin` class:\n\n```kotlin\nclass MyAwesomePlugin : Plugin() {\n\n    override fun onEnable() {\n        // Setup your plugin here\n    }\n\n}\n```\n\nAnd add a `main` function to your application to start it:\n\n```kotlin\nfun main(args: Array\u003cString\u003e) = MyAwesomePlugin().main(args)\n```\n\nUpdate your `build.gradle(.kts)` to register your plugin id and main class:\n\n```kotlin\napplication {\n    mainClass = \"me.nathanfallet.myawesomeplugin.MyAwesomePluginKt\"\n}\n\nstreamDeckPlugin {\n    pluginId = \"me.nathanfallet.myawesomeplugin\"\n}\n```\n\n### Handle events\n\nTo handle events, create a [usecase](https://github.com/nathanfallet/usecases) that implements `IHandleEventUseCase`.\n\nThere are two ways to handle events:\n\n- Have one usecase per event type\n- Have one usecase that routes events to other usecases\n\n#### One usecase per event type\n\n```kotlin\nclass HandleKeyDownUseCase : IHandleEventUseCase {\n\n    override suspend fun invoke(input1: IEvent, input2: IPlugin) {\n        if (input1 !is KeyDownEvent) return\n\n        println(\"Key down event received for key ${input1.payload.coordinates.column}x${input1.payload.coordinates.row}\")\n    }\n\n}\n```\n\nAnd register it in your plugin:\n\n```kotlin\nclass MyAwesomePlugin : Plugin() {\n\n    override fun onEnable() {\n        // Setup your plugin here\n\n        registerUseCase(HandleKeyDownUseCase()) // Add this\n    }\n\n}\n```\n\n#### One usecase that routes events to other usecases\n\n```kotlin\nclass HandleEventsUseCase(\n    private val handleKeyDownUseCase: HandleKeyDownUseCase,\n    // Add other usecases here\n) : IHandleEventUseCase {\n\n    override suspend fun invoke(input1: IEvent, input2: IPlugin) {\n        when (input1) {\n            is KeyDownEvent -\u003e handleKeyDownUseCase(input1, input2)\n            else -\u003e return // Ignore other events\n        }\n    }\n\n}\n```\n\n```kotlin\nclass HandleKeyDownUseCase : IPairSuspendUseCase\u003cKeyDownEvent, IPlugin\u003e {\n\n    override suspend fun invoke(input1: KeyDownEvent, input2: IPlugin) {\n        println(\"Key down event received for key ${input1.payload.coordinates.column}x${input1.payload.coordinates.row}\")\n    }\n\n}\n```\n\nAnd register it in your plugin:\n\n```kotlin\nclass MyAwesomePlugin : Plugin() {\n\n    override fun onEnable() {\n        // Setup your plugin here\n\n        registerUseCase(\n            HandleEventsUseCase(\n                HandleKeyDownUseCase(),\n                // Add other usecases here\n            )\n        )\n    }\n\n}\n```\n\n### Build the plugin\n\nCreate a `manifest.json` file in your `src/main/resources` folder (along with any other assets you want to include in\nthe plugin, like action icons).\n\nThanks to the gradle plugin, you can use the `./gradlew buildStreamDeckPlugin` command (or the `buildStreamDeckPlugin`\ntask from your IDE) to build the `build/\u003cpluginId\u003e.sdPlugin` folder containing the plugin.\n\nYou might also need to adjust the manifest file first for it to match with your gradle project name:\n\n```json\n{\n  \"CodePathMac\": \"bin/my-awesome-plugin\",\n  \"CodePathWin\": \"bin/my-awesome-plugin.bat\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanfallet%2Fstreamdeck-kotlin-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanfallet%2Fstreamdeck-kotlin-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanfallet%2Fstreamdeck-kotlin-sdk/lists"}