summaryrefslogtreecommitdiff
path: root/scripts/.local/bin
diff options
context:
space:
mode:
authorivan-boikov <ik.boikov.public@protonmail.com>2024-08-18 19:20:32 +0200
committerivan-boikov <ik.boikov.public@protonmail.com>2024-08-18 19:20:32 +0200
commit63d1a6b8b17cbcec7aeae2f65a468eeca670271c (patch)
treef111d6d01b90d9655a325237be68a3e8b94a9636 /scripts/.local/bin
parent15b0c61c821bc66da75dfca3a81b5d903fd0eb58 (diff)
ncmpcpp: update cover to tmp
Diffstat (limited to 'scripts/.local/bin')
-rwxr-xr-xscripts/.local/bin/on_song_change14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/.local/bin/on_song_change b/scripts/.local/bin/on_song_change
new file mode 100755
index 0000000..243d706
--- /dev/null
+++ b/scripts/.local/bin/on_song_change
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# https://gist.github.com/vlevit/4588882
+MUSIC_DIR="$HOME/audio/music"
+album="$(mpc --format %album% current)"
+file="$(mpc --format %file% current)"
+album_dir="${file%/*}"
+[[ -z "$album_dir" ]] && exit 1
+album_dir="$MUSIC_DIR/$album_dir"
+
+covers="$(find "$album_dir" -type d -exec find {} -maxdepth 1 -type f -iregex ".*/.*\(${album}\|cover\|folder\|artwork\|front\).*[.]\(jpe?g\|png\|gif\|bmp\)" \; )"
+cover="$(echo -n "$covers" | head -n1)"
+
+cp -f "$cover" /tmp/mpd.cover