Ranger: How can I run a process in the background?

Created on 6 Apr 2018  路  4Comments  路  Source: ranger/ranger

Is there any way I can run a process in the 'background'?

I'm using the following to 'preview' an audio file:
map <F1> shell mplayer -endpos 0:00:03 %s > /dev/null 2>&1 &

However it seems to 'flash' the screen when doing the above, and I was wonder if there is some way to avoid this.

Most helpful comment

Change it to shell -f, this forks the process. You could also add a rule to rifle.conf so preview would be the default action or list in the ask menu, press r then the number.
Also as a sidenote, check out mpv it improves on mplayer/mplayer2 a lot.

All 4 comments

Change it to shell -f, this forks the process. You could also add a rule to rifle.conf so preview would be the default action or list in the ask menu, press r then the number.
Also as a sidenote, check out mpv it improves on mplayer/mplayer2 a lot.

@toonn if you can fork mplayer or any other program, why am I not able fork rifle?
map O shell -f rifle %s or map O shell -f python rifle %s don't work, only opening in a terminal worked map O shell -f kitty rifle %s.
does rifle only work from within a terminal? i.e for text files runs " " and not " , then why is it also not working for audio/video files with mpv (meaning not opening audio/video file in new mpv window without showing mpv's standard output in ranger).

What i'm trying to do is open file (whatever it is, text file or audio/video) in new window, whatever it is terminal window or mpv.

Thanks, I'm pretty sure this was solved with the comment from @toonn . @wis you might want to open a new issue and add additional information.

@wis, when you fork the command is run as a separate process, if this process then outputs anything to stdout you won't get to see that output. There's flag t for such programs in rifle, that forks a new terminal and then runs the command in there. With GUI programs on the other hand you're not interested in its output only the window it spawns, so flag t isn't ideal. There's no way to determine whether a program spawns a new window or not so ranger can't automatically determine whether to use flag f or t. You could hack something up with heuristics or something though.

Was this page helpful?
0 / 5 - 0 ratings