diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-26 02:18:09 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-26 02:18:09 +0900 |
| commit | 2ff3a2e98363423fd0fceac2708e8050b266a58e (patch) | |
| tree | 99d07be215a58662e521a122126be58c9daeb82b /ar/.local/bin/dmenudelmusic | |
| parent | 9c9f856b5ba1501d5743712e198504eaa9539b20 (diff) | |
Diffstat (limited to 'ar/.local/bin/dmenudelmusic')
| -rwxr-xr-x | ar/.local/bin/dmenudelmusic | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/ar/.local/bin/dmenudelmusic b/ar/.local/bin/dmenudelmusic index 91994fb..fce8db2 100755 --- a/ar/.local/bin/dmenudelmusic +++ b/ar/.local/bin/dmenudelmusic @@ -1,7 +1,9 @@ #!/bin/sh music_dir="${XDG_MUSIC_DIR:-${HOME}/Music}" -music_txt="${music_dir}/.music.txt" +dotfiles_dir="${XDG_DOTFILES_DIR:-${HOME}/.dotfiles}" +music_txt="${dotfiles_dir}/global/Music/.music.txt" +music_titles="${dotfiles_dir}/global/Music/.music_titles.txt" playlist_dir="${XDG_CONFIG_HOME:-${HOME}/.config}/mpd/playlists" # Select the relative path. Sort the list so "first match" semantics in dmenu @@ -34,8 +36,15 @@ confirm=$(printf "Yes\nNo" | dmenu -i -p "Delete $selected_relpath and update mp exit 0 } -# Remove video_id line from .music.txt (fixed-string match) -if grep -Fv "$video_id" "$music_txt" >"${music_txt}.tmp" && mv "${music_txt}.tmp" "$music_txt"; then +# Remove video_id line from .music.txt and .music_titles.txt (fixed-string match) +remove_id_from() { + _file="$1" + [ -f "$_file" ] || return 0 + _tmp="$(mktemp)" || return 1 + grep -Fv "$video_id" "$_file" >"$_tmp" && mv "$_tmp" "$_file" +} + +if remove_id_from "$music_txt" && remove_id_from "$music_titles"; then # Remove the relative path from playlists (-F avoids regex pitfalls with [], (), etc.) for playlist in "$playlist_dir"/*.m3u; do [ -e "$playlist" ] || continue |
