From 6e3ec7b9ef6c920b26d8ed37e84d1eceb9e4c52d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 2 Oct 2016 23:47:06 +0200 Subject: degrade gracefully --- hel/recv-media.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'hel') diff --git a/hel/recv-media.nix b/hel/recv-media.nix index d9ad5d29..5a9a8505 100644 --- a/hel/recv-media.nix +++ b/hel/recv-media.nix @@ -8,7 +8,7 @@ , gnused ? null }: -assert showTitle -> ffmpeg != null && gnused != null; +assert showTitle -> ffmpeg != null && gnused != null && notifyUser != null; writeScriptBin "recv-media" '' #!${stdenv.shell} @@ -33,12 +33,11 @@ writeScriptBin "recv-media" '' touch -c -m -t "$2" "''${target}" fi + ${if notifyUser == null then "" else "#"}exit 0 + ( - summary=$(ffmpeg -i "''${target}" -f ffmetadata pipe:1 2>/dev/null | sed -r '/^title=/!d; s/^title=//') - if [[ -z "''${summary}" ]]; then - echo "Title is empty, replacing with filename" >&2 - summary=$(basename "$1") - fi + summary=$(${if showTitle then ''ffmpeg -i "''${target}" -f ffmetadata pipe:1 2>/dev/null | sed -r '/^title=/!d; s/^title=//''' else ''""'' fi) + [[ -z "''${summary}" ]] && summary=$(basename "$1") printf "%s\n%s\n" "''${summary}" "" | notify-${notifyUser} -a recv-media || true ) || true '' -- cgit v1.2.3