Initial commit

This commit is contained in:
Emery Hemingway 2022-03-21 10:40:02 -05:00
commit 2e17001bd3
5 changed files with 54 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
synmpc

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# synmpc
Enques songs to MPD from Syndicate assertions. Uses the same `<xdg-open @uris [string ...]>` assertions as [xdg_open_ng](https://git.syndicate-lang.org/ehmry/xdg_open_ng).

12
config.pr Normal file
View File

@ -0,0 +1,12 @@
let ?root_ds = dataspace
<bind "syndicate" #x"" $root_ds>
<require-service <daemon synmpc>>
<daemon synmpc {
argv: ["/home/repo/syndicate/synmpc/src/synmpc" ""]
protocol: text/syndicate
clearEnv: #t
}>
? <service-object <daemon synmpc> ?cap> [ $cap [ <listen-on $root_ds> ] ]

25
src/synmpc.nim Normal file
View File

@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: ☭ 2022 Emery Hemingway
# SPDX-License-Identifier: Unlicense
import std/asyncdispatch
import preserves
import syndicate
import mpdclient
type
XdgOpen {.preservesRecord: "xdg-open".} = object
uris: seq[string]
ListenOn {.preservesRecord: "listen-on".} = ref object
dataspace: Preserve[Ref]
bootDataspace("main") do (root: Ref; turn: var Turn):
connectStdio(root, turn)
let mpd = newMPDClient()
onPublish(turn, root, ?ListenOn) do (a: Assertion):
stderr.writeLine "got listen-on ", a
let ds = unembed a
onMessage(turn, ds, ?XdgOpen) do (uris: seq[string]):
for uri in uris: mpd.add uri
runForever()

13
synmpc.nimble Normal file
View File

@ -0,0 +1,13 @@
# Package
version = "0.1.0"
author = "Emery Hemingway"
description = "Syndicate MPD client"
license = "Unlicense"
srcDir = "src"
bin = @["synmpc"]
# Dependencies
requires "nim >= 1.6.4", "syndicate >= 1.2.1", "mpdclient"