Adjust to Syndicate-nim changes

This commit is contained in:
Emery Hemingway 2023-05-18 12:41:37 +01:00
parent 8c322d1efd
commit 2a1a3fe200
4 changed files with 26 additions and 22 deletions

View File

@ -1,4 +1,5 @@
let ?socketPath = "/run/user/1000/mpv.sock"
let ?mpvSpace = dataspace
$mpvSpace [
; announce the dataspace when the translator is connected
@ -8,16 +9,17 @@ $mpvSpace [
; translate <play-file …> to an MPV command
?? <play-file ?file> [
$log ! <log "-" { line: <play-file $file> }>
! <send-json { "command": ["loadfile" $file "append-play"] }>
]
; log anything that comes back from MPV
; ?? <recv-json ?js> [ $log ! <log "-" { mpv: $js }> ]
; clear the playlist on idle so it doesn't grow indefinitely
?? <recv-json {"event": "idle"}> [
! <send-json { "command": ["playlist-clear"] }>
]
; log anything that comes back from MPV
?? <recv-json ?js> [ $log ! <log "-" { mpv: $js }> ]
]
; need the translator and the translator needs the daemon
@ -32,17 +34,7 @@ $mpvSpace [
]
; assert and retract the daemon as the daemon is built (this is a testing artifact)
? <built "json_socket_translator" ?path ?sum> [
<daemon mpv-server {
argv: [
"/run/current-system/sw/bin/mpv"
"--really-quiet"
"--idle=yes"
"--no-audio-display"
"--input-ipc-server=/run/user/1000/mpv.sock"
]
protocol: none
}>
? <built json_socket_translator ?path ?sum> [
<daemon mpv-translator {
argv: [$path]
@ -50,3 +42,15 @@ $mpvSpace [
env: {BUILD_SUM: $sum}
}>
]
; start mpv regardless
<daemon mpv-server {
argv: [
"/run/current-system/sw/bin/mpv"
"--really-quiet"
"--idle=yes"
"--no-audio-display"
"--input-ipc-server=/run/user/1000/mpv.sock"
]
protocol: none
}>

View File

@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: ☭ Emery Hemingway
# SPDX-License-Identifier: Unlicense
import std/[asyncdispatch, json, os, osproc, strutils]
import std/[json, os, osproc]
import preserves # , preserves/jsonhooks,
import syndicate

View File

@ -4,15 +4,15 @@
import std/[asyncdispatch, sequtils, os]
import preserves, syndicate, syndicate/capabilities
proc unixSocketPath: string =
result = getEnv("SYNDICATE_SOCK")
if result == "":
result = getEnv("XDG_RUNTIME_DIR", "/run/user/1000") / "dataspace"
proc unixSocketPath: Unix =
result.path = getEnv("SYNDICATE_SOCK")
if result.path == "":
result.path = getEnv("XDG_RUNTIME_DIR", "/run/user/1000") / "dataspace"
proc main =
let label = getAppFilename().extractFilename
bootDataspace(label) do (root: Ref; turn: var Turn):
connectUnix(turn, unixSocketPath(), capabilities.mint()) do (turn: var Turn; ds: Ref):
connect(turn, unixSocketPath(), capabilities.mint().toPreserve(Ref)) do (turn: var Turn; ds: Ref):
message(turn, ds, initRecord(label, map(commandLineParams(), parsePreserves)))
for i in 0..3: poll(20)

View File

@ -1,6 +1,6 @@
# Package
version = "20230517"
version = "20230518"
author = "Emery Hemingway"
description = "Utilites for Syndicated Actors and Synit"
license = "unlicense"
@ -10,4 +10,4 @@ bin = @["json_socket_translator", "json_translator", "msg"]
# Dependencies
requires "nim >= 1.6.6", "syndicate >= 20230517"
requires "nim >= 1.6.6", "syndicate >= 20230518"