summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2018-06-02 18:09:36 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2018-06-02 18:09:36 +0200
commitbde0545ce84224d5c24ce5062940ab8754ae49d9 (patch)
treef8c73a76dbc2d289c20717df10adf9c3f99b71b3
parent0a6b4afd95b381b44e59717839250e2bcbe248a1 (diff)
downloadnixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.tar
nixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.tar.gz
nixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.tar.bz2
nixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.tar.xz
nixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.zip
...
-rw-r--r--custom/recv-media.sh10
-rw-r--r--custom/uucp-mediaclient.nix9
2 files changed, 10 insertions, 9 deletions
diff --git a/custom/recv-media.sh b/custom/recv-media.sh
index 29e3d158..f99aaaf0 100644
--- a/custom/recv-media.sh
+++ b/custom/recv-media.sh
@@ -7,7 +7,7 @@ exec 2> >(@utillinux@/bin/logger --id=$pid -t recv-media -p user.error)
7 7
8[[ -z "$1" || -z "$2" ]] && exit 2 8[[ -z "$1" || -z "$2" ]] && exit 2
9 9
10dir=@mediaDir@ 10dir=@mediadir@
11group=$(@coreutils@/bin/stat -c '%G' $dir) 11group=$(@coreutils@/bin/stat -c '%G' $dir)
12tmpFile="${dir}/.tmp/${1:t}" 12tmpFile="${dir}/.tmp/${1:t}"
13target="${dir}/${1:t}" 13target="${dir}/${1:t}"
@@ -25,7 +25,7 @@ EOF
25 25
26if [[ $(id -Gn) != *"$group"* ]]; then 26if [[ $(id -Gn) != *"$group"* ]]; then
27 printf "Groups are ‘%s’. Trying to switch primary group to ‘%s’..." $(id -Gn) $group 27 printf "Groups are ‘%s’. Trying to switch primary group to ‘%s’..." $(id -Gn) $group
28 exec -- @wrapperDir@/sg $group "$0 $*" 28 exec -- @wrapperdir@/sg $group "$0 $*"
29fi 29fi
30 30
31typeset -a failures 31typeset -a failures
@@ -40,13 +40,13 @@ failures=()
40 @coreutils@/bin/touch -c -m -t "$2" "${target}" || failures+="touch" 40 @coreutils@/bin/touch -c -m -t "$2" "${target}" || failures+="touch"
41) 41)
42 42
43if @doNotify@ && [[ $#failures -gt 0 ]]; then 43if @donotify@ && [[ $#failures -gt 0 ]]; then
44 printf "%s\n%s\n%s" "${target:t}" "Failed to download" ${(j:, :)failures} | @notify@ -a recv-media -u Critical 44 printf "%s\n%s\n%s" "${target:t}" "Failed to download" ${(j:, :)failures} | @notify@ -a recv-media -u Critical
45fi 45fi
46 46
47if @doNotify@; then 47if @donotify@; then
48 ( 48 (
49 if @showTitle@; then 49 if @showtitle@; then
50 summary=$(@ffmpeg@/bin/ffmpeg -i "${target}" -f ffmetadata pipe:1 2>/dev/null | sed -r '/\[CHAPTER\]/q; /^title=/!d; s/^title=//') 50 summary=$(@ffmpeg@/bin/ffmpeg -i "${target}" -f ffmetadata pipe:1 2>/dev/null | sed -r '/\[CHAPTER\]/q; /^title=/!d; s/^title=//')
51 else 51 else
52 summary=${target:t} 52 summary=${target:t}
diff --git a/custom/uucp-mediaclient.nix b/custom/uucp-mediaclient.nix
index ab949150..7c7f2743 100644
--- a/custom/uucp-mediaclient.nix
+++ b/custom/uucp-mediaclient.nix
@@ -16,16 +16,17 @@ let
16 ''; 16 '';
17 17
18 inherit zsh coreutils utillinux; 18 inherit zsh coreutils utillinux;
19 inherit (config.security) wrapperDir; 19 wrapperdir = config.security.wrapperDir;
20 inherit (cfg) mediaDir; 20 mediadir = cfg.mediaDir;
21 doNotify = cfg.notify.users != []; 21 donotify = cfg.notify.users != [];
22 showtitle = cfg.notify.extractTitle;
22 ffmpeg = if doNotify then ffmpeg-full else "/no-such-path"; 23 ffmpeg = if doNotify then ffmpeg-full else "/no-such-path";
23 notify = writeScript "notify.sh" '' 24 notify = writeScript "notify.sh" ''
24 #!${zsh}/bin/zsh 25 #!${zsh}/bin/zsh
25 26
26 input=$(cat) 27 input=$(cat)
27 28
28 ${concatMapStringsSep "\n" (name: ''${wrapperDir}/notify-${name} $@ <<<''${input}'') cfg.notify.users} 29 ${concatMapStringsSep "\n" (name: ''${wrapperdir}/notify-${name} $@ <<<''${input}'') cfg.notify.users}
29 ''; 30 '';
30 31
31 buildPhase = '' 32 buildPhase = ''