aboutsummaryrefslogtreecommitdiffstats
path: root/.config/cmus/cover-art/observe.sh
blob: 5777f6c9a16c2ce469c64a8d888b0607449aca34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

CURRENT_DIR=`dirname "$BASH_SOURCE"`
COVERS_DIR="$CURRENT_DIR/.cover"

status=$2
file_path=$(echo "$@" | grep -o  "file .*\...." | sed s/file\ //)
timestamp=`date +%s`

rm $COVERS_DIR/*
if [ $status == "playing" ]
then
  ffmpeg -i "${file_path}" -an -vcodec copy $COVERS_DIR/${timestamp}.jpg
  if [ ! -f "$COVERS_DIR/${timestamp}.jpg" ]
  then
    file_dir=$(dirname "${file_path}")
    cp "${file_dir}/cover.jpg" $COVERS_DIR/${timestamp}.jpg || cp "${file_dir}/folder.jpg" $COVERS_DIR/${timestamp}.jpg
  fi
fi