summaryrefslogtreecommitdiff
path: root/mpc-notify
diff options
context:
space:
mode:
authornoodle <shawtynoodle@gmail.com>2023-07-02 00:38:05 +0300
committernoodle <shawtynoodle@gmail.com>2023-07-06 14:52:40 +0300
commit0cb713aa7ff7cc42f0da42da55ac90fb5d531ec3 (patch)
tree058704db52d5658fd202f0fe087886ac351c499f /mpc-notify
parent659f0db2353ddc43ebf8ff7ba2c88393f3287767 (diff)
mpc-notify: use xdg-user-dirs for finding music directory
Diffstat (limited to 'mpc-notify')
-rwxr-xr-xmpc-notify21
1 files changed, 17 insertions, 4 deletions
diff --git a/mpc-notify b/mpc-notify
index 4bd80a1..ab6d43e 100755
--- a/mpc-notify
+++ b/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" ]; 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