feat(cmus): improve notification and information display
This commit is contained in:
parent
5d22d6aea0
commit
70384e0f7f
2 changed files with 38 additions and 15 deletions
|
@ -9,36 +9,59 @@ process_args() {
|
|||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
filename=${file#*/}
|
||||
image=${file%/*}/cover.jpg
|
||||
[ -f "$image" ] && options="$options -i \"${image}\""
|
||||
#
|
||||
escape(){
|
||||
local string
|
||||
string=$1
|
||||
string=${string//"<"/"<"}
|
||||
string=${string//">"/">"}
|
||||
string=${string//"&"/"&"}
|
||||
printf "%s" "$string"
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
options=( --app-name=cmus --transient -u low)
|
||||
|
||||
filename=${file##*/}
|
||||
image=${file%/*}/cover.jpg
|
||||
|
||||
if [[ -f "$image" ]]; then
|
||||
options+=( -i "${image}" )
|
||||
fi
|
||||
|
||||
## Get title or filename
|
||||
title=${title:-$filename}
|
||||
if [[ ${#title} -gt 25 ]]; then
|
||||
title="${title:0:24}…"
|
||||
fi
|
||||
title="<b>$title</b>"
|
||||
|
||||
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}…"
|
||||
artist="${artist:0:21}…"
|
||||
fi
|
||||
printf -v l_artist "<span size='x-large'>by </span>%s" "$(escape "$artist")"
|
||||
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"
|
||||
|
||||
# Get Album
|
||||
if [ -n "$album" ]
|
||||
then
|
||||
if [[ ${#album} -gt 19 ]]; then
|
||||
album="${album:0:19}…"
|
||||
fi
|
||||
printf -v l_album "<span size='x-large'>on </span>%-20s <span size='x-large'>%s</span>" "$(escape "$album")" "${date:-}"
|
||||
fi
|
||||
|
||||
printf -v l_intro "<span variant='small-caps'>cmus:<b>%s</b></span>" "$(escape "$status")"
|
||||
printf -v body "%s\n" "${l_intro:-}" "${title:-}" "${l_artist:-}" "${l_album:-}"
|
||||
notify-send "${options[@]}" "unseless" "$body"
|
||||
}
|
||||
|
||||
process_args "$@"
|
||||
|
|
|
@ -52,5 +52,5 @@ set color_win_inactive_sel_fg=20
|
|||
set color_win_dir=default
|
||||
|
||||
set status_display_program=~/.config/cmus/notify.sh
|
||||
|
||||
set format_current= %{?stream??} %t %{?a?by %a} %{?l?on %l}%= %y
|
||||
add -l ~/medias/music
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue