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/default.nix | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'pkgs/profpatsch/xdg-open/default.nix') diff --git a/pkgs/profpatsch/xdg-open/default.nix b/pkgs/profpatsch/xdg-open/default.nix index e73f8093..89114b92 100644 --- a/pkgs/profpatsch/xdg-open/default.nix +++ b/pkgs/profpatsch/xdg-open/default.nix @@ -83,6 +83,14 @@ let ] ++ args file; }; + fetch-http-url-mime = { + exe = writeExecline "fetch-http-url-mime" { readNArgs = 1; } [ + "pipeline" [ read-headers-and-follow-redirect "$1" ] + record-get [ "content-type" ] + printenv "content-type" + ]; + args = file: [ file ]; + }; Prelude = let src = (import ./imports.nix { inherit pkgs; }).Prelude; @@ -106,6 +114,7 @@ let : { compose-mail-to : Command , dmenu-list-binaries-and-exec : Command , exec-in-terminal-emulator : ∀ ( args: Command) → Command + , fetch-http-url-mime : Command , open-in-browser : Command , open-in-editor : Command } @@ -132,6 +141,7 @@ let inherit compose-mail-to open-in-browser + fetch-http-url-mime open-in-editor dmenu-list-binaries-and-exec exec-in-terminal-emulator @@ -150,11 +160,11 @@ let ]; stderr-prog = writeExecline "stderr-prog" {} [ - "foreground" [ bins.echo "$@" ] + "if" [ "fdmove" "-c" "1" "2" bins.echo "$@" ] "$@" ]; - http-request = writeExecline "http-request-for-url" { } [ + http-request = writeExecline "http-request" { } [ "importas" "-i" "protocol" "protocol" "ifelse" [ bins.s6-test "$protocol" "=" "http" ] [ (http-https-request false) ] "ifelse" [ bins.s6-test "$protocol" "=" "https" ] [ (http-https-request true) ] @@ -177,9 +187,15 @@ let "" ]) "$path" "$host" ] + stderr-tee + stderr-prog + "pipeline" ([ bins.nc ] ++ lib.optional isHttps "-c" ++ [ - "-N" "$host" "$port" + "-v" "-N" "$host" "$port" + ]) + stderr-tee + "cat" ]); printenv = writeRustSimple "printenv" {} @@ -245,7 +261,6 @@ let go ]); - read-http = writeRustSimple "read-http" { dependencies = [ httparse netencode-rs ]; buildInputs = [ pkgs.skalibs ]; -- cgit 1.4.1