From be43605785732a92fba1f95e3337fa1f60f6f124 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Fri, 5 Mar 2021 22:42:55 +0100 Subject: pkgs/profpatsch/xdg-open: improve tool a bit --- pkgs/profpatsch/xdg-open/xdg-open.dhall | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'pkgs/profpatsch/xdg-open/xdg-open.dhall') diff --git a/pkgs/profpatsch/xdg-open/xdg-open.dhall b/pkgs/profpatsch/xdg-open/xdg-open.dhall index 03f168c3..30cf45e0 100644 --- a/pkgs/profpatsch/xdg-open/xdg-open.dhall +++ b/pkgs/profpatsch/xdg-open/xdg-open.dhall @@ -13,11 +13,6 @@ let let config = ./config.dhall -let foo = - { match = [ "image", "png" ] - , cmd = λ(_ : Text) → { exe = "echo", args = [ "foo" ] } - } - let renderMime = Text/concatSep "/" let shellEscapeCommand = @@ -66,12 +61,28 @@ let xdg-open = ] let mimeGlobCase = + λ(shellEscape2 : Text → Text) → + λ(file2 : Text) → λ(g : config.UriMimeGlob) → List/concatMap Text Text ( λ(match : Text) → - [ "${match})", "mime=${renderMime g.mime}", ";;" ] + merge + { Mime = + λ(mime : config.Mime) → + [ "${match})", "mime=${renderMime mime}", ";;" ] + , Transparent = + λ(cmd : config.Command) → + [ "${match})" + , "mime=\"\$(${shellEscapeCommand + shellEscape2 + file2 + cmd})\"" + , ";;" + ] + } + g.handler ) g.glob : List Text @@ -102,8 +113,8 @@ let xdg-open = List/concatMap config.UriMimeGlob Text - mimeGlobCase - config.uriMimeGlobs + (mimeGlobCase shellEscape "\"\$file\"") + (config.uriMimeGlobs special) }} *) # it’s a file -- cgit 1.4.1