feat(home-manager): add cmus module
This commit is contained in:
parent
11309754fa
commit
dbea61d652
5 changed files with 120 additions and 0 deletions
45
modules/home-manager/audio/cmus/files/notify.sh
Executable file
45
modules/home-manager/audio/cmus/files/notify.sh
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/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
|
Loading…
Add table
Add a link
Reference in a new issue