diff --git a/modules/home-manager/audio/cmus/files/notify.sh b/modules/home-manager/audio/cmus/files/notify.sh index d11fbff..dfc62db 100755 --- a/modules/home-manager/audio/cmus/files/notify.sh +++ b/modules/home-manager/audio/cmus/files/notify.sh @@ -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="$title" if [ -n "$artist" ] then if [[ ${#artist} -gt 22 ]]; then - artist="by ${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 "by %s" "$(escape "$artist")" fi if [ -n "$date" ] then date="${date%%-*}" fi - printf -v body "%s\n%-19s %s" "${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 "on %-20s %s" "$(escape "$album")" "${date:-}" + fi + + printf -v l_intro "cmus:%s" "$(escape "$status")" + printf -v body "%s\n" "${l_intro:-}" "${title:-}" "${l_artist:-}" "${l_album:-}" + notify-send "${options[@]}" "unseless" "$body" } process_args "$@" diff --git a/modules/home-manager/audio/cmus/files/rc b/modules/home-manager/audio/cmus/files/rc index ea71c79..2c30746 100644 --- a/modules/home-manager/audio/cmus/files/rc +++ b/modules/home-manager/audio/cmus/files/rc @@ -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 diff --git a/modules/home-manager/desktop/sway/includes/mako.nix b/modules/home-manager/desktop/sway/includes/mako.nix index 81ddf7e..7f4de74 100644 --- a/modules/home-manager/desktop/sway/includes/mako.nix +++ b/modules/home-manager/desktop/sway/includes/mako.nix @@ -26,6 +26,7 @@ with lib; maxIconSize = 64; layer = "overlay"; anchor = "top-right"; + format = ''%a\n%s\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=%s\n%b + format=%b ''; }; };