I have the following function
play-music()
{
local selected=$(find "${PWD}" -mindepth 1 -maxdepth 1 -type f -iname "*.mp3" | LC_COLLATE=C sort | fzf)
local processed=""
while IFS= read -r line; do
processed+="$line\n"
done <<< "$selected"
echo -e "${processed}" | xargs -d '\n' mpv # How to execute this line as a detached process without showing any message from mpv in the terminal
}
This function works, but as long as mpv
is playing, it is showing the mpv
messages in the terminal and I can't close the terminal. So, is there a way to execute the last line as a detached process? So that it won't show any mpv
messages in the terminal and I can close the terminal, if I want, after mpv
has started playing the files?
For example, the following doesn't work
echo -e "${processed}" | xargs -d '\n' mpv </dev/null &>/dev/null & disown
echo -e "${processed}" | xargs -d '\n' mpv
could become:
(
set +m
exec &>/dev/null </dev/null
echo -e "${processed}" | xargs -d '\n' mpv &
disown
)
or specifically for mpv:
(
set +m;
echo -e "${processed}" | xargs -d '\n' mpv --no-terminal &
disown
)