about summary refs log tree commit diff
path: root/pkgs/profpatsch/xdg-open/xdg-open.dhall
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-03-05 22:42:55 +0100
committerProfpatsch <mail@profpatsch.de>2021-03-05 22:56:29 +0100
commitbe43605785732a92fba1f95e3337fa1f60f6f124 (patch)
treef6da9bb97cab3d41d284fe7b01f09b771d13a92c /pkgs/profpatsch/xdg-open/xdg-open.dhall
parent009cb2bab9777e87d362584bb5992ad90631568e (diff)
pkgs/profpatsch/xdg-open: improve tool a bit
Diffstat (limited to 'pkgs/profpatsch/xdg-open/xdg-open.dhall')
-rw-r--r--pkgs/profpatsch/xdg-open/xdg-open.dhall27
1 files changed, 19 insertions, 8 deletions
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