0

when i run this script with a shortcut(sxhkd):

#!/bin/sh

MUSIC_DIR="$HOME/music"

songs=$(ls "$MUSIC_DIR")

filename=$( echo -e "random\n$songs" | dmenu -l 30 -i -p "Play >> ")

if [[ $filename = "random" ]]
then
    filename=$(ls "$MUSIC_DIR" |shuf -n 1)
fi

if [[ -f "$MUSIC_DIR/$filename" ]]
then
    notify-send -t 2500 "$filename is playing" &&  mpv "$MUSIC_DIR/$filename" --no-audio-display
else
    notify-send -t 1500 "typo?"
fi

I want to open a terminal control mpv process on it ( get the mpv terminal interface ).

I have tried reptyr, but I'm getting this error.

~ λ  reptyr $(pgrep mpv)
[-] Process 514610 (dmenuMusic) shares 514636's process group. Unable to attach.
(This most commonly means that 514636 has sub-processes).
Unable to attach to pid 514636: Invalid argument

also tried:

~ λ  echo 0 | doas tee /proc/sys/kernel/yama/ptrace_scope

It just didn't work, gave me same error.

10
  • To the new terminal: reptyr. The process won't become a child of the new shell though. Nov 18, 2023 at 19:21
  • I have edited the question to include my try. I didn't have success using that Nov 18, 2023 at 20:12
  • 2
    Have you considered getting used to tmux or screen? Nov 18, 2023 at 21:25
  • 2
    tmux is fully scriptable. You have a shortcut that runs some script anyway. But I don't know what "script dmenuMusic" is and how it affects things. Anyway, I have just tested and reptyr can do what you want to do, when the command is exactly mpv song.mp3 & disown. So I think your problem with it is because of dmenuMusic, whatever it is. I guess the question does not show us the actual command, i.e. it's not MCVE. And probably it's an XY problem. You want to control mpv, not necessarily to reown it. Nov 18, 2023 at 22:26
  • 1
    sorry for the inconvenience I have edited my questino to be more MCVE. Nov 18, 2023 at 23:34

0

You must log in to answer this question.

Browse other questions tagged .