Commit Diff


commit - 659f0db2353ddc43ebf8ff7ba2c88393f3287767
commit + 0cb713aa7ff7cc42f0da42da55ac90fb5d531ec3
blob - 4bd80a178e915c01febc67785360f3c13b2f9a72
blob + ab6d43e6e547e6e26d86b6622d03b38fa80a1272
--- mpc-notify
+++ mpc-notify
@@ -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" ]; the
 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% - %alb
 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