Compare commits
2 commits
5d22d6aea0
...
0e22d1d36a
Author | SHA1 | Date | |
---|---|---|---|
0e22d1d36a | |||
70384e0f7f |
3 changed files with 41 additions and 16 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
|
||||
|
|
|
@ -26,6 +26,7 @@ with lib;
|
|||
maxIconSize = 64;
|
||||
layer = "overlay";
|
||||
anchor = "top-right";
|
||||
format = ''<span font_scale="small-caps">%a</span>\n<b>%s</b>\n%b'';
|
||||
extraConfig = ''
|
||||
[urgency="high"]
|
||||
border-color=#F268b3
|
||||
|
@ -34,9 +35,10 @@ with lib;
|
|||
border-size=1
|
||||
default-timeout=7000
|
||||
group-by=app-name
|
||||
format=%b
|
||||
|
||||
[app-name="cmus" grouped]
|
||||
format=<b>%s</b>\n%b
|
||||
format=%b
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue