nix/modules/home-manager/audio/cmus/files/notify.sh

45 lines
903 B
Bash
Executable file

#!/usr/bin/env bash
# shellcheck disable=SC2154
process_args() {
while [ "$#" -ge 2 ]
do
printf -v "$1" "%s" "$2"
shift
shift
done
}
main() {
filename=${file#*/}
image=${file%/*}/cover.jpg
[ -f "$image" ] && options="$options -i \"${image}\""
title=${title:-$filename}
if [[ ${#title} -gt 25 ]]; then
title="${title:0:24}"
fi
if [ -n "$artist" ]
then
if [[ ${#artist} -gt 22 ]]; then
artist="<i>by</i> ${artist:0:21}"
fi
fi
if [ -n "$album" ]
then
if [[ ${#album} -gt 19 ]]; then
album="${album:0:18}"
fi
fi
if [ -n "$date" ]
then
date="${date%%-*}"
fi
printf -v body "%s\n%-19s <i>%s</i>" "${artist:-}" "${album:-}" "${date:-}"
notify-send --app-name=cmus -i "$image" "$title" "$body"
}
process_args "$@"
main