[download]

local/bin/playing

   1 #!/bin/bash
   2 
   3 IFS=  read icon tl file artist album title < <(
   4 player -f '$icon $tl $file $artist $album $title') || { notify player; exit; }
   5 
   6 [[ $file != /* ]] &&
   7 file=~/Музыка/$file
   8 
   9 cover=/tmp/$$.png
  10 pics=("${file%/*}/"*.jpg)
  11 head="$artist"
  12 body="$icon $title ($tl)"
  13 
  14 [[ $artist ]] || head=$body body=
  15 [[ $album  ]] && body+="\n\n[ $album ]"
  16 
  17 [[ $file =~ https://www.youtube.com/watch\?v=(.+)$ ]] && pics=$cover &&
  18 wget -qO $cover https://i1.ytimg.com/vi/${BASH_REMATCH[1]}/hqdefault.jpg
  19 
  20 ffmpeg -i "$file" $cover 2>&- || cp "$pics" $cover
  21 convert $cover -thumbnail '100x>^' $cover ||
  22 printf '<svg width="22" height="22"><text font-family="Nerdfont"
  23 y="18" font-size="20" fill="#fff"></text></svg>' > $cover
  24 
  25 notify-send -a ${0##*/} -i $cover -- "$head" "$body"
  26 rm -f $cover