diff options
author | boredpasta <boredpasta@tutanota.com> | 2023-07-17 17:59:59 +0300 |
---|---|---|
committer | boredpasta <boredpasta@tutanota.com> | 2023-07-17 17:59:59 +0300 |
commit | bebbb737a532680e092afccedb7e91aaa37be124 (patch) | |
tree | 87a7b0ef464d44d19c80d3fe9b94188c3c423909 | |
parent | 289051ee3ce04da6c07f5374fa5ba1c7606cf9d7 (diff) |
mpc-notify: documentation
-rwxr-xr-x | mpc-notify | 35 |
1 files changed, 21 insertions, 14 deletions
@@ -1,19 +1,24 @@ #!/bin/sh -e # Based on: # https://wiki.archlinux.org/title/Ncmpcpp#With_album_art - -# Sends notification of currently playing MPD music with album cover art. +# +# mpc-notify: sends notification of currently playing MPD music accompanied +# by album cover art. +# # Dependencies: # mpc # ffmpeg # notify-send # and my other script, notify-replace. # recommended: a home directory setup with xdg-user-dirs (for finding your -# music directory -# For notification on song change: -# Assign execute_on_song_change to this script in ncmpcpp's config file. -# For notification on media keys: -# Bind media key to a call to mpc with the approprite command. +# music directory) +# +# For getting notifications on media keys: +# Bind media key to calls to mpc-notify instead of mpc or other media +# controllers. +# For getting notifications on song change, add: +# execute_on_song_change = "mpc-notify" +# to your ncmpcpp's configuration file. # exit early if we're in tty if [ -z "$WAYLAND_DISPLAY" ] && [ -z "$DISPLAY" ]; then @@ -68,6 +73,7 @@ case "$command" in "off") song_head="Single Mode: Off";; esac + # TODO: consider a more appropriate icon song_icon="multimedia-player" ;; "random") @@ -79,6 +85,7 @@ case "$command" in "off") song_head="Random Mode: Off";; esac + # TODO: consider a more appropriate icon song_icon="media-eject" ;; "repeat") @@ -95,7 +102,7 @@ case "$command" in *) mpc -q "$command" # don't notify if mpc changed song because ncmpcpp would notify on - # song change anway + # song change anyway [ "$command" = "next" ] || [ "$command" = "prev" ] && exit ;; esac @@ -112,12 +119,12 @@ if [ "$use_preview" -eq 1 ]; then # get preview filename song_filename="$(mpc --format "${xdg_music_dir}/%file%" current)" - song_album="$(mpc --format %album% current)" - if [ -z "$song_album" ]; then - # fallback to default for empty album name + song_album_name="$(mpc --format %album% current)" + if [ -z "$song_album_name" ]; then + # fallback to the default icon for an empty album name song_icon="$default_song_icon" else - preview_path="${preview_dir}/$(echo "$song_album" | base64).png" + preview_path="${preview_dir}/$(echo "$song_album_name" | base64).png" if [ -f "$preview_path" ]; then # use cached preview song_icon="$preview_path" @@ -146,9 +153,9 @@ if [ "$use_preview" -eq 1 ]; then fi unset preview_path fi -unset xdg_music_dir song_filename song_album +unset xdg_music_dir song_filename song_album_name -# send the actual notification +# now send the actual notification song_body="$(mpc --format '[%title%[ \n%artist% - %album%]]|[%file%]' current)" notify-replace 'mpc-notify' "$song_head" "$song_body" -i "$song_icon" -u low |