diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-06-26 14:57:41 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-06-26 14:57:41 +0900 |
| commit | 7a511cf1f8c6b6ca55e6965e1e04e25d948ea735 (patch) | |
| tree | 55a00093cf816312999b94d5d45934687e92d01d /ar/.local/bin/dmenudelmusic | |
| parent | 71da06956dbc932246d8a7e70b409a47af6fe9e1 (diff) | |
updates
Diffstat (limited to 'ar/.local/bin/dmenudelmusic')
| -rwxr-xr-x | ar/.local/bin/dmenudelmusic | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ar/.local/bin/dmenudelmusic b/ar/.local/bin/dmenudelmusic index fce8db2..9f5540c 100755 --- a/ar/.local/bin/dmenudelmusic +++ b/ar/.local/bin/dmenudelmusic @@ -45,12 +45,18 @@ remove_id_from() { } if remove_id_from "$music_txt" && remove_id_from "$music_titles"; then - # Remove the relative path from playlists (-F avoids regex pitfalls with [], (), etc.) + # Remove the relative path from every playlist (entire.m3u + genre lists like + # jpop/kpop/pop). -F avoids regex pitfalls with [], (), etc. + # These .m3u files are symlinks into the dotfiles repo, so write the result + # back with `cat > "$playlist"` (which follows the symlink) instead of + # `mv`/`sed -i`, both of which would replace the symlink with a plain file. for playlist in "$playlist_dir"/*.m3u; do [ -e "$playlist" ] || continue if grep -Fq "$selected_relpath" "$playlist"; then - grep -Fv "$selected_relpath" "$playlist" > "${playlist}.tmp" && mv "${playlist}.tmp" "$playlist" - sed -i '/^$/d' "$playlist" + _pl_tmp="$(mktemp)" || continue + grep -Fv "$selected_relpath" "$playlist" | sed '/^$/d' > "$_pl_tmp" + cat "$_pl_tmp" > "$playlist" + rm -f "$_pl_tmp" fi done |
