diff options
author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-10-02 23:47:06 +0200 |
---|---|---|
committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-10-02 23:47:06 +0200 |
commit | 6e3ec7b9ef6c920b26d8ed37e84d1eceb9e4c52d (patch) | |
tree | da603c10fa04aef4ded626de7f25eff3939d2329 /hel | |
parent | a781c344eadd68cb670aff7c3a5feda8891203ff (diff) | |
download | nixos-6e3ec7b9ef6c920b26d8ed37e84d1eceb9e4c52d.tar nixos-6e3ec7b9ef6c920b26d8ed37e84d1eceb9e4c52d.tar.gz nixos-6e3ec7b9ef6c920b26d8ed37e84d1eceb9e4c52d.tar.bz2 nixos-6e3ec7b9ef6c920b26d8ed37e84d1eceb9e4c52d.tar.xz nixos-6e3ec7b9ef6c920b26d8ed37e84d1eceb9e4c52d.zip |
degrade gracefully
Diffstat (limited to 'hel')
-rw-r--r-- | hel/recv-media.nix | 11 |
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 | ||
11 | assert showTitle -> ffmpeg != null && gnused != null; | 11 | assert showTitle -> ffmpeg != null && gnused != null && notifyUser != null; |
12 | 12 | ||
13 | writeScriptBin "recv-media" '' | 13 | writeScriptBin "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 | '' |