From eefe0786f98e200845d5cc1811cae2b93f720201 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 20 Aug 2013 13:55:39 +0200 Subject: [PATCH] nixos-help: Use xdg-open if available --- modules/services/misc/nixos-manual.nix | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/services/misc/nixos-manual.nix b/modules/services/misc/nixos-manual.nix index 108ed2911ce0..90e596fdc50d 100644 --- a/modules/services/misc/nixos-manual.nix +++ b/modules/services/misc/nixos-manual.nix @@ -21,10 +21,18 @@ let help = pkgs.writeScriptBin "nixos-help" '' #! ${pkgs.stdenv.shell} -e - if ! ''${BROWSER:-w3m} ${entry}; then - echo "$0: unable to start a web browser; please set \$BROWSER or install ‘w3m’" - exit 1 + browser="$BROWSER" + if [ -z "$browser" ]; then + browser="$(type -P xdg-open || true)" + if [ -z "$browser" ]; then + browser="$(type -P w3m || true)" + if [ -z "$browser" ]; then + echo "$0: unable to start a web browser; please set \$BROWSER" + exit 1 + fi + fi fi + exec "$browser" ${entry} ''; in