Advertisement
Dobbie03

np script

Sep 11th, 2021
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. set -euf -o pipefail
  3.  
  4. # CONFIG ----------------------------------------------------
  5. # This NEEDS to be the same as in mpd.conf
  6. # music_dir="$HOME/Music/Albums"
  7. music_dir="$HOME/Music"
  8.  
  9. # What should the covers be resized to in pixels
  10. cover_resize="200"
  11.  
  12. # What is the cover file called?
  13. img_reg=".*/(cover|front|folder|art).(jpg|jpeg|png|gif)$"
  14.  
  15. # What do we want the notification to look like?
  16. artist_color="##c6c6c6"
  17. song_color="##a4a4a4"
  18.  
  19. form="<span color='$artist_color'>%artist%</span> - <span color='$song_color'>%title%</span>"
  20. # END CONFIG ------------------------------------------------
  21.  
  22. # These are some variables we need for things to work
  23. song="$(mpc --format %file% current)"
  24. songdir="$music_dir/$(dirname "${song}")/"
  25. raw_cover="/tmp/current_cover.png"
  26. heading="$(mpc current -f "%album%" | sed "s:&:&amp;:g")"
  27. message="$(mpc current -f "$form" | sed "s:&:&amp;:g" )"
  28.  
  29. # Is there music on?
  30. [[ -z $song ]] && exit 1
  31.  
  32. # No cover if the folder isn't found
  33. [[ -z "$songdir" ]] && exit 1
  34.  
  35. # But if it is found, look for only one of the specified files
  36. cover="$(find "$songdir" -maxdepth 1 -type f -regextype egrep -regex "$img_reg" 2>/dev/null)"
  37.  
  38. # Resize the cover
  39. if [[ -n $cover ]]; then
  40. ffmpeg -hide_banner -loglevel panic -nostats -y -i "$cover" -vf scale="$cover_resize":-2 "$raw_cover"
  41. cover="$raw_cover"
  42. fi
  43.  
  44. # Send the notification
  45. notify-send -u low -t 8000 -i "$cover" "$heading" "$message"
  46.  
  47. # add a rule to make sxiv:albumcover floating
  48. #sxiv "$cover" -N albumcover -g 250x250-10-10 -bpq > /dev/null 2>&1 & pid=$!
  49. # { sleep 4; kill "$pid"; } &
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement