diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2018-06-02 18:09:36 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2018-06-02 18:09:36 +0200 |
commit | bde0545ce84224d5c24ce5062940ab8754ae49d9 (patch) | |
tree | f8c73a76dbc2d289c20717df10adf9c3f99b71b3 | |
parent | 0a6b4afd95b381b44e59717839250e2bcbe248a1 (diff) | |
download | nixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.tar nixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.tar.gz nixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.tar.bz2 nixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.tar.xz nixos-bde0545ce84224d5c24ce5062940ab8754ae49d9.zip |
...
-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 = '' |