diff options
author | Profpatsch <mail@profpatsch.de> | 2021-05-12 23:37:42 +0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2021-05-12 23:42:13 +0200 |
commit | 986330f5162b308e63d8ae228d54240c1e73ad90 (patch) | |
tree | 8ec55bc3f9d935549859baf42f7964afdec93a0b /pkgs/profpatsch/xdg-open/xdg-open.dhall | |
parent | ba600abbfe2a123a5293511a21aec18b9d7d4818 (diff) |
pkgs/profpatsch/xdg-open: directly pass MimeMatch to xdg-open script
No use in passing through the mime type now that we can just directly render the commands in the protocol handlers. This gives us the base for generating the Firefox handlers.json.
Diffstat (limited to 'pkgs/profpatsch/xdg-open/xdg-open.dhall')
-rw-r--r-- | pkgs/profpatsch/xdg-open/xdg-open.dhall | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/pkgs/profpatsch/xdg-open/xdg-open.dhall b/pkgs/profpatsch/xdg-open/xdg-open.dhall index cd9e8d4c..66ab88a3 100644 --- a/pkgs/profpatsch/xdg-open/xdg-open.dhall +++ b/pkgs/profpatsch/xdg-open/xdg-open.dhall @@ -15,13 +15,17 @@ let types = ./types.dhall let renderMime = Text/concatSep "/" -let shellEscapeCommand = +let + -- Escape the given shell command, at least the String arguments of it. + -- Passes `$file` as variable argument. + -- The final shell command is executed into. + shellEscapeExecCommand = λ(shellEscape : Text → Text) → λ(file : Text) → λ(cmd : types.Command) → Text/concatSep " " - ( [ shellEscape cmd.exe ] + ( [ "exec", shellEscape cmd.exe ] # List/map types.Arg Text @@ -56,7 +60,7 @@ let xdg-open = λ(file2 : Text) → λ(m : types.MimeMatch) → [ "${renderMime m.mime})" - , "${shellEscapeCommand shellEscape2 file2 m.cmd}" + , "${shellEscapeExecCommand shellEscape2 file2 m.cmd}" , ";;" ] @@ -70,12 +74,18 @@ let xdg-open = ( λ(match : Text) → merge { Mime = - λ(mime : types.Mime) → - [ "${match})", "mime=${renderMime mime}", ";;" ] + λ(mime : types.MimeMatch) → + [ "${match})" + , shellEscapeExecCommand + shellEscape2 + file2 + mime.cmd + , ";;" + ] , Transparent = λ(cmd : types.Command) → [ "${match})" - , "mime=\"\$(${shellEscapeCommand + , "mime=\"\$(${shellEscapeExecCommand shellEscape2 file2 cmd})\"" |