syndicated-open/uri_runner.pr

69 lines
2.2 KiB
Plaintext

; Expose a dataspace over a unix socket
let ?socketspace = dataspace
<require-service <relay-listener <unix "/run/user/1000/dataspace"> $gatekeeper>>
<bind "syndicate" #x"" $socketspace>
; Create a new dataspace for receiving "exec" messages
; from the uri_runner
let ?execspace = dataspace
$execspace ?? <exec ?argv> $config [
let ?id = timestamp
let ?facet = facet
let ?d = <uri_runner-exec $id $argv>
<run-service <daemon $d>>
<daemon $d {
argv: $argv,
env: { WAYLAND_DISPLAY: "wayland-1" DISPLAY: ":0" XDG_CACHE_HOME: "/home/cache" }
readyOnStart: #f,
restart: =never,
}>
? <service-state <daemon $d> complete> [$facet ! stop]
? <service-state <daemon $d> failed> [$facet ! stop]
]
; Start the uri_runner
<require-service <daemon uri_runner>>
<daemon uri_runner {
argv: "uri_runner"
protocol: text/syndicate
}>
? <service-object <daemon uri_runner> ?cap> $cap [
; send configuration to uri_runner
<listen-on $socketspace>
; When http* is matched send a message to $execspace
; that indicates the Syndicate server should start Firefox.
<action-handler "(http://.*|https://.*|.*html)" $execspace
<exec ["/bin/firefox" "--new-tab" "$1"]>>
; Capture a pattern within a pattern
<action-handler "https://twitter.com/(.*)" $execspace
<exec ["/bin/firefox" "--new-tab" "https://nitter.net/$1"]>>
; Local file-system paths should always be prefixed
; by file:// but that can be removed after matching
<action-handler "file://(.*.pdf)" $execspace
<exec ["/bin/mupdf" "$1"]>>
<action-handler "(magnet:?.*xt=urn:btih.*)" $execspace
<exec ["/bin/transmission-remote-gtk" "$1"]>>
<action-handler "(tox:.*)|uri:(tox:.*)" $execspace
<exec ["/bin/qtox" "$1"]>>
<action-handler "(gemini://.*|file:///.*.gmi)" $execspace
<exec ["/bin/lagrange" "$1"]>>
<action-handler "(https://.*\\.twitch.tv/.*)" $execspace
<exec ["/bin/streamlink" "-p" "mpv" "$1"]>>
; when the mpv-transator is available send it commands directly
$config ? <service-object <daemon mpv-translator> ?mpv> $mpv [
$cap <action-handler "(.*\\.avi|.*\\.mkv|.*mp4|.*ogg|.*youtu.*|.*\\.m3u8|.*webm)" $mpv
<mpv 1 { "command": ["loadfile" "$1" "append-play"] }>>
]
]