diff options
author | Profpatsch <mail@profpatsch.de> | 2021-03-05 22:42:55 +0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2021-03-05 22:56:29 +0100 |
commit | be43605785732a92fba1f95e3337fa1f60f6f124 (patch) | |
tree | f6da9bb97cab3d41d284fe7b01f09b771d13a92c /pkgs/profpatsch/xdg-open/config.dhall | |
parent | 009cb2bab9777e87d362584bb5992ad90631568e (diff) |
pkgs/profpatsch/xdg-open: improve tool a bit
Diffstat (limited to 'pkgs/profpatsch/xdg-open/config.dhall')
-rw-r--r-- | pkgs/profpatsch/xdg-open/config.dhall | 68 |
1 files changed, 48 insertions, 20 deletions
diff --git a/pkgs/profpatsch/xdg-open/config.dhall b/pkgs/profpatsch/xdg-open/config.dhall index 9820df96..a66c888e 100644 --- a/pkgs/profpatsch/xdg-open/config.dhall +++ b/pkgs/profpatsch/xdg-open/config.dhall @@ -35,36 +35,52 @@ let mime = let renderMime = λ(m : Mime) → 32 -let UriMimeGlob = { desc : Text, glob : List Text, mime : Mime } - -let uriMimeGlobs - : List UriMimeGlob - = [ { desc = "http link" - , glob = [ "http://*", "https://*" ] - , mime = mime.text.html - } - , { glob = [ "mailto:*" ] - , desc = "mail address" - , mime = mime.mail-address - } - , { glob = [ "magnet:*" ] - , desc = "bittorrent magnet link" - , mime = mime.torrent - } - , { desc = "irc channel", glob = [ "irc:*" ], mime = mime.irc } - , { desc = "local file", glob = [ "file://*" ], mime = mime.file } - ] +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 MimeMatch = { match : Mime, cmd : Command } +let UriMimeGlob = { desc : Text, glob : List Text, handler : UriGlobHandler } 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 } +let uriMimeGlobs + : Special → List UriMimeGlob + = λ(special : Special) → + [ { desc = "http link" + , glob = [ "http://*", "https://*" ] + , handler = + let TODO = UriGlobHandler.Transparent special.fetch-http-url-mime + + in UriGlobHandler.Mime mime.text.html + } + , { glob = [ "mailto:*" ] + , desc = "mail address" + , handler = UriGlobHandler.Mime mime.mail-address + } + , { glob = [ "magnet:*" ] + , desc = "bittorrent magnet link" + , handler = UriGlobHandler.Mime mime.torrent + } + , { desc = "irc channel" + , glob = [ "irc:*" ] + , handler = UriGlobHandler.Mime mime.irc + } + , { desc = "local file" + , glob = [ "file://*" ] + , handler = UriGlobHandler.Mime mime.file + } + ] + +let MimeMatch = { match : Mime, cmd : Command } + let mimeMatcher = λ(pkgs : { package : Text, binary : Text } → Executable) → λ(special : Special) → @@ -75,6 +91,17 @@ let mimeMatcher = , 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 ] } @@ -114,6 +141,7 @@ in { mimeMatcher , UriMimeGlob , Executable , Command + , UriGlobHandler , MimeMatch , Special , Mime |