about summary refs log tree commit diff
path: root/pkgs/profpatsch/xdg-open/types.dhall
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-05-12 23:05:28 +0200
committerProfpatsch <mail@profpatsch.de>2021-05-12 23:42:13 +0200
commit0d1737778cf81304ec37cea2a1c0e934bb84e601 (patch)
tree85dd4f2de036adb61fcd18ddb66aa2ad08d49c56 /pkgs/profpatsch/xdg-open/types.dhall
parent08bb67826b793e57b8ec17627ba2a52478567700 (diff)
pkgs/profpatsch/xdg-open: prepare for adding firefox handler support
This diff is a bit bad cause of whitespace changes, but effectively
this copies all handlers into the mime handler definitions and
duplicates them for now.

We want to use the same config to generate a firefox mime handler
file.
Diffstat (limited to 'pkgs/profpatsch/xdg-open/types.dhall')
-rw-r--r--pkgs/profpatsch/xdg-open/types.dhall50
1 files changed, 50 insertions, 0 deletions
diff --git a/pkgs/profpatsch/xdg-open/types.dhall b/pkgs/profpatsch/xdg-open/types.dhall
new file mode 100644
index 00000000..74e55d32
--- /dev/null
+++ b/pkgs/profpatsch/xdg-open/types.dhall
@@ -0,0 +1,50 @@
+let Mime = List Text
+
+let
+    -- TODO use library like with shell commands
+    Executable =
+      Text
+
+let Arg = < String : Text | Variable : Text >
+
+let CommandTemplate =
+      λ(templates : Type) → { exe : Executable, args : templates → List Arg }
+
+let Command = CommandTemplate Arg
+
+let Special =
+      { open-in-editor : Command
+      , open-in-browser : Command
+      , fetch-http-url-mime : Command
+      , compose-mail-to : Command
+      , exec-in-terminal-emulator : ∀(args : Command) → Command
+      , dmenu-list-binaries-and-exec : Command
+      , notify : ∀(message : Text) → Command
+      }
+
+let
+    -- Handler of an uri glob. Mime maps the uri to a file handler. Transparent is a command which, when run, returns a mimetype of the file.
+    UriGlobHandler =
+      < Transparent : Command | Mime : Mime >
+
+let UriMimeGlob =
+      { desc : Text
+      , -- less specific than glob, used by firefox to refer to the schema
+        schema-prefix : List Text
+      , -- schema shell glob to check whether a link corresponds to the schema
+        glob : List Text
+      , handler : UriGlobHandler
+      }
+
+let MimeMatch = { match : Mime, cmd : Command }
+
+in  { Mime
+    , Executable
+    , Arg
+    , CommandTemplate
+    , Command
+    , Special
+    , UriGlobHandler
+    , UriMimeGlob
+    , MimeMatch
+    }