diff options
-rwxr-xr-x | mpc-notify | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -2,8 +2,14 @@ # Based on: # https://wiki.archlinux.org/title/Ncmpcpp#With_album_art -# Sends notification for mpd with album cover art. Uses mpc, ffmpeg, -# notify-send, and my other script, notify-replace. +# Sends notification of currently playing MPD music with 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: @@ -15,11 +21,19 @@ if [ -z "$WAYLAND_DISPLAY" ] && [ -z "$DISPLAY" ]; then fi command="$1" +# set defaults # FEATURE: make width and height configurable through flags preview_width=64 preview_height=64 default_song_icon="media-playback-start" + +# find xdg directories xdg_config_home="${XDG_CONFIG_HOME:-$HOME/.config}" +xdg_user_dirs="${xdg_config_home}/user-dirs.dirs" +[ -f "$xdg_user_dirs" ] && source "$xdg_user_dirs" +xdg_music_dir="${XDG_MUSIC_DIR:-$HOME/Music}" + +# find mpc config directory mpc_config_dir="$xdg_config_home/mpc" [ -d "$mpc_config_dir" ] || mkdir -p "$mpc_config_dir" @@ -92,10 +106,9 @@ song_body="$(mpc --format '[%title%[ \n%artist% - %album%]]|[%file%]' current)" if [ "$use_preview" -eq 1 ]; then preview_dir="$mpc_config_dir/previews" [ -d "$preview_dir" ] || mkdir -p "$preview_dir" - music_dir="$(xdg-user-dir MUSIC)" # get preview filename - song_filename="$(mpc --format "$music_dir"/%file% current)" + 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 |