summaryrefslogtreecommitdiff
path: root/hel
diff options
context:
space:
mode:
Diffstat (limited to 'hel')
-rw-r--r--hel/recv-media.nix11
1 files changed, 5 insertions, 6 deletions
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 @@
8, gnused ? null 8, gnused ? null
9}: 9}:
10 10
11assert showTitle -> ffmpeg != null && gnused != null; 11assert showTitle -> ffmpeg != null && gnused != null && notifyUser != null;
12 12
13writeScriptBin "recv-media" '' 13writeScriptBin "recv-media" ''
14 #!${stdenv.shell} 14 #!${stdenv.shell}
@@ -33,12 +33,11 @@ writeScriptBin "recv-media" ''
33 touch -c -m -t "$2" "''${target}" 33 touch -c -m -t "$2" "''${target}"
34 fi 34 fi
35 35
36 ${if notifyUser == null then "" else "#"}exit 0
37
36 ( 38 (
37 summary=$(ffmpeg -i "''${target}" -f ffmetadata pipe:1 2>/dev/null | sed -r '/^title=/!d; s/^title=//') 39 summary=$(${if showTitle then ''ffmpeg -i "''${target}" -f ffmetadata pipe:1 2>/dev/null | sed -r '/^title=/!d; s/^title=//''' else ''""'' fi)
38 if [[ -z "''${summary}" ]]; then 40 [[ -z "''${summary}" ]] && summary=$(basename "$1")
39 echo "Title is empty, replacing with filename" >&2
40 summary=$(basename "$1")
41 fi
42 printf "%s\n%s\n" "''${summary}" "" | notify-${notifyUser} -a recv-media || true 41 printf "%s\n%s\n" "''${summary}" "" | notify-${notifyUser} -a recv-media || true
43 ) || true 42 ) || true
44'' 43''