syndicated-open/uri_runner.pr

51 lines
1.7 KiB
Plaintext

; Expose a dataspace over a unix socket
let ?root_ds = dataspace
<require-service <relay-listener <unix "/run/user/1000/dataspace"> $gatekeeper>>
<bind "syndicate" #x"" $root_ds>
<require-service <daemon uri_runner>>
<daemon uri_runner {
argv: "uri_runner"
protocol: text/syndicate
}>
? <service-object <daemon uri_runner> ?cap> [
; send configuration to uri_runner
$cap [
<listen-on $root_ds>
; Here the "0" argument is replaced with the whole URI asserted by xdg-open.
<action-handler "http://.*|https://.*|.*html", ["/run/current-system/sw/bin/librewolf" 0]>
; An argument can be a reference to a capture.
<action-handler "(tox:.*)|uri:(tox:.*)", ["/run/current-system/sw/bin/qtox" 1]>
; An argument can contain a reference to a capture using the $i notation.
<action-handler "https://twitter.com/(.*)" ["/run/current-system/sw/bin/librewolf" "https://nitter.net/$1"]>
<action-handler "gemini://.*|file:///.*.gmi" ["/run/current-system/sw/bin/kristall" 0]>
<action-handler ".*\\.avi|.*\\.mkv|.*\\.mp4|.*\\.ogg|.*\\.opus", ["/run/current-system/sw/bin/mpv" 0]>
; filesystem paths are always prefixed with file://
<action-handler "file://(.*.pdf)" ["/run/current-system/sw/bin/mupdf" 1]>
]
; uri_runner sends messages to the server to start handler applications
$cap ?? <exec ?argv ?restartPolicy> [
let ?id = timestamp
let ?facet = facet
let ?d = <uri_runner-exec $id $argv>
$config <run-service <daemon $d>>
$config <daemon $d {
argv: $argv,
readyOnStart: #f,
restart: $restartPolicy,
}>
$config ? <service-state <daemon $d> complete> [$facet ! stop]
$config ? <service-state <daemon $d> failed> [$facet ! stop]
]
]