From bf1fd1dbb46e66f001f5e7ea64b0a56435f29157 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sun, 17 Oct 2021 12:23:29 +0200 Subject: [PATCH] config/shell: export music directory globally --- .config/shell/music | 2 -- .local/bin/scripts/focus | 12 +++++++----- .local/bin/scripts/mp | 4 ++-- .zprofile | 4 +++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.config/shell/music b/.config/shell/music index 07c0463..1438973 100644 --- a/.config/shell/music +++ b/.config/shell/music @@ -1,5 +1,3 @@ -export DATA="$(test -d $HOME/data && echo $HOME/data || echo $HOME/daten)" -export MUSIC="$DATA/music" export AUDIO="$DATA/audio" MUSIC_RAW="$AUDIO/songs/_raw" diff --git a/.local/bin/scripts/focus b/.local/bin/scripts/focus index 6e7e407..a8d0bb2 100755 --- a/.local/bin/scripts/focus +++ b/.local/bin/scripts/focus @@ -1,12 +1,14 @@ #!/bin/sh -e -# launch my focus playlist -playlistPath="$MUSIC/Playlists" +# launch my focus playlist or find a matching playlist or song files +# depends: mp mpc +# env: MUSIC +PLAYLISTS="$MUSIC/Playlists" mpc clear if test -z "$1" -then mp -q "$playlistPath/focus.m3u" +then mp -q "$PLAYLISTS/focus.m3u" else - (find -L $playlistPath -iname "focus-$1.m3u" -print0 | grep --null-data . || - find -L $playlistPath -iname "$1.m3u*" -print0 | grep --null-data . || + (find -L $PLAYLISTS -iname "focus-$1.m3u" -print0 | grep --null-data . || + find -L $PLAYLISTS -iname "$1.m3u*" -print0 | grep --null-data . || find -L $MUSIC -iname "*$1*" -prune -exec find {} -size +2M -type f -not -iregex ".*.\(jpe?g\|png\)" -print0 \; ) | xargs -0 mp -q fi diff --git a/.local/bin/scripts/mp b/.local/bin/scripts/mp index 7db2d43..695ba03 100755 --- a/.local/bin/scripts/mp +++ b/.local/bin/scripts/mp @@ -1,6 +1,6 @@ #!/bin/sh # Play given files on mpd, enabling playing of external files through symlinking and recursively resolving playlists -# depends: xargs mpc realpath +# depends: xargs realpath mpc # env: MUSIC MUSIC="${MUSIC:-$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/mpd/mpd.conf | grep music_directory | cut -d'"' -f2 | sed "s|~|$HOME|")}" PLAYLISTS="$MUSIC/Playlists" @@ -31,5 +31,5 @@ else { "$0" -r "$@" && mpc -q update --wait; } | #>/tmp/mp 2>&1 xargs --delim='\n' mpc insert mpc ${quiet:-$next} play - test -n "$next" && mpc $quiet next + test -z "$next" || mpc $quiet next fi diff --git a/.zprofile b/.zprofile index 1cc0d5a..61ce85a 100644 --- a/.zprofile +++ b/.zprofile @@ -1,5 +1,7 @@ +export DATA="$(test -d $HOME/data && echo $HOME/data || echo $HOME/daten)" +export MUSIC="$DATA/music" + # xdg -export DATA="$HOME/data" export XDG_DATA_HOME="$HOME/.local/share" export XDG_STATE_HOME="$HOME/.local/state" export XDG_CACHE_HOME="$HOME/.local/cache"