diff options
-rw-r--r-- | custom/recv-media.sh | 10 | ||||
-rw-r--r-- | custom/uucp-mediaclient.nix | 9 |
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 | ||
10 | dir=@mediaDir@ | 10 | dir=@mediadir@ |
11 | group=$(@coreutils@/bin/stat -c '%G' $dir) | 11 | group=$(@coreutils@/bin/stat -c '%G' $dir) |
12 | tmpFile="${dir}/.tmp/${1:t}" | 12 | tmpFile="${dir}/.tmp/${1:t}" |
13 | target="${dir}/${1:t}" | 13 | target="${dir}/${1:t}" |
@@ -25,7 +25,7 @@ EOF | |||
25 | 25 | ||
26 | if [[ $(id -Gn) != *"$group"* ]]; then | 26 | if [[ $(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 $*" |
29 | fi | 29 | fi |
30 | 30 | ||
31 | typeset -a failures | 31 | typeset -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 | ||
43 | if @doNotify@ && [[ $#failures -gt 0 ]]; then | 43 | if @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 |
45 | fi | 45 | fi |
46 | 46 | ||
47 | if @doNotify@; then | 47 | if @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 = '' |