about summary refs log tree commit diff
path: root/pkgs/profpatsch
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-05-12 23:15:48 +0200
committerProfpatsch <mail@profpatsch.de>2021-05-12 23:42:13 +0200
commitba600abbfe2a123a5293511a21aec18b9d7d4818 (patch)
treef4e8946fff37f9f0807818db0f00dcbb0235cdf3 /pkgs/profpatsch
parent0d1737778cf81304ec37cea2a1c0e934bb84e601 (diff)
pkgs/profpatsch/xdg-open: use the new matcher list
Removes the duplication of command handlers.
Diffstat (limited to 'pkgs/profpatsch')
-rw-r--r--pkgs/profpatsch/xdg-open/config.dhall79
-rw-r--r--pkgs/profpatsch/xdg-open/default.nix1
-rw-r--r--pkgs/profpatsch/xdg-open/types.dhall5
-rw-r--r--pkgs/profpatsch/xdg-open/xdg-open.dhall4
4 files changed, 10 insertions, 79 deletions
diff --git a/pkgs/profpatsch/xdg-open/config.dhall b/pkgs/profpatsch/xdg-open/config.dhall
index 45ef45d1..2b1fb686 100644
--- a/pkgs/profpatsch/xdg-open/config.dhall
+++ b/pkgs/profpatsch/xdg-open/config.dhall
@@ -113,7 +113,7 @@ in  λ(pkgs : { package : Text, binary : Text } → Executable) →
                   { mime = [ "*" ], cmd = special.dmenu-list-binaries-and-exec }
                 }
 
-      let matchOrder =
+      let orderedMimeMatchers =
             [ mime.text.html
             , mime.text.gemini
             , mime.text.gopher
@@ -175,82 +175,9 @@ in  λ(pkgs : { package : Text, binary : Text } → Executable) →
               }
             ]
 
-      let mimeMatcher =
-            let pkgSame =
-                  λ(packageAndBinaryName : Text) →
-                    pkgs
-                      { package = packageAndBinaryName
-                      , binary = packageAndBinaryName
-                      }
-
-            let wrapCommand =
-                  λ(wrapper : Command) →
-                  λ(cmd : Command) →
-                    { exe = wrapper.exe
-                    , args =
-                        λ(template : Arg) →
-                            wrapper.args template
-                          # [ Arg.String cmd.exe ]
-                          # cmd.args template
-                    }
-
-            let oneArg =
-                  λ(exe : Executable) → { exe, args = λ(file : Arg) → [ file ] }
-
-            let m = λ(match : Mime) → λ(cmd : Command) → { match, cmd }
-
-            in    [ { match = mime.mail-address.mime
-                    , cmd = special.compose-mail-to
-                    }
-                  , { match = mime.text.html.mime
-                    , cmd = special.open-in-browser
-                    }
-                  , { match = mime.text.gemini.mime
-                    , cmd = oneArg (pkgSame "lagrange")
-                    }
-                  , { match = mime.text.gopher.mime
-                    , cmd = oneArg (pkgSame "lagrange")
-                    }
-                  , { match = mime.text.xml.mime
-                    , cmd = special.open-in-browser
-                    }
-                  , { match = mime.text.any.mime, cmd = special.open-in-editor }
-                  , { match = mime.image.gif.mime
-                    , cmd = special.open-in-browser
-                    }
-                  , { match = mime.image.svg.mime
-                    , cmd = oneArg (pkgSame "inkscape")
-                    }
-                  , { match = mime.image.any.mime
-                    , cmd = oneArg (pkgSame "imv")
-                    }
-                  , { match = mime.pdf.mime, cmd = oneArg (pkgSame "zathura") }
-                  , { match = mime.pgp-key.mime
-                    , cmd =
-                      { exe = pkgs { package = "gnupg", binary = "gpg" }
-                      , args =
-                          λ(file : Arg) →
-                            [ Arg.String "--import"
-                            , Arg.String "--import-options"
-                            , Arg.String "show-only"
-                            , file
-                            ]
-                      }
-                    }
-                  , { match = mime.directory.mime
-                    , cmd =
-                        special.exec-in-terminal-emulator
-                          (oneArg (pkgSame "ranger"))
-                    }
-                  , { match = mime.any.mime
-                    , cmd = special.dmenu-list-binaries-and-exec
-                    }
-                  ]
-                : List MimeMatch
-
-      in  { mimeMatcher
-          , uriMimeGlobs
+      in  { uriMimeGlobs
           , UriMimeGlob
+          , orderedMimeMatchers
           , Executable
           , Command
           , UriGlobHandler
diff --git a/pkgs/profpatsch/xdg-open/default.nix b/pkgs/profpatsch/xdg-open/default.nix
index 2b265318..97418958 100644
--- a/pkgs/profpatsch/xdg-open/default.nix
+++ b/pkgs/profpatsch/xdg-open/default.nix
@@ -149,6 +149,7 @@ let
         open-in-editor
         dmenu-list-binaries-and-exec
         exec-in-terminal-emulator
+        notify
         ;
     };
 
diff --git a/pkgs/profpatsch/xdg-open/types.dhall b/pkgs/profpatsch/xdg-open/types.dhall
index 74e55d32..72184ad5 100644
--- a/pkgs/profpatsch/xdg-open/types.dhall
+++ b/pkgs/profpatsch/xdg-open/types.dhall
@@ -36,7 +36,10 @@ let UriMimeGlob =
       , handler : UriGlobHandler
       }
 
-let MimeMatch = { match : Mime, cmd : Command }
+let
+    -- describes the command `cmd` to run for the matched mime type `mime`
+    MimeMatch =
+      { mime : Mime, cmd : Command }
 
 in  { Mime
     , Executable
diff --git a/pkgs/profpatsch/xdg-open/xdg-open.dhall b/pkgs/profpatsch/xdg-open/xdg-open.dhall
index 5090f8f1..cd9e8d4c 100644
--- a/pkgs/profpatsch/xdg-open/xdg-open.dhall
+++ b/pkgs/profpatsch/xdg-open/xdg-open.dhall
@@ -55,7 +55,7 @@ let xdg-open =
             λ(shellEscape2 : Text → Text) →
             λ(file2 : Text) →
             λ(m : types.MimeMatch) →
-              [ "${renderMime m.match})"
+              [ "${renderMime m.mime})"
               , "${shellEscapeCommand shellEscape2 file2 m.cmd}"
               , ";;"
               ]
@@ -140,7 +140,7 @@ let xdg-open =
                                   types.MimeMatch
                                   Text
                                   (mimeMatcherCase shellEscape "\"\$file\"")
-                                  config.mimeMatcher
+                                  config.orderedMimeMatchers
                             }}
                         esac
                         ''