Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spawned apps detaching from Clifm #262

Open
ErinVoid opened this issue Nov 19, 2023 · 22 comments
Open

Spawned apps detaching from Clifm #262

ErinVoid opened this issue Nov 19, 2023 · 22 comments
Labels

Comments

@ErinVoid
Copy link

Is your feature request related to a problem? Please describe.
The documentation is not clear but would like to spawn an application, i.e. mpv, and the clifm instance return to the prompt rather than await the application quitting. Am using Lira as the opener.

Additional context
Clifm is good but not easy for mortals to understand from the documentation. Coming from nnn (as it doesn't [plugins especially nuke] play well with Alpine's standard Busybox install). Maybe the documentation could do with better structure and certainly be a little more consistent such as whenever a keypress is required, quote the necessary keys. However, getting into Clifm with previews for images so thank you.

@leo-arch
Copy link
Owner

leo-arch commented Nov 19, 2023

Hi @ErinVoid. Edit Lira's config file (via mm edit) and add this line under the Video and audio section (delete/comment out the old line or place the new one on top of it):

X:^video/.*=xterm -e mpv %f &

This instructs clifm to open video files in the background using mpv on a separate instance of xterm (The focus will be on the newly created window, but clifm will immediately generate a new prompt).

As to the docs, thanks for the observation; I will take a look at it. Please feel free to edit it as you see it fits.

getting into Clifm with previews for images so thank you.

You're welcome!

@ErinVoid
Copy link
Author

Thank for the feedback. The above doesn't work with Sakura which does spawn a new term but opens some random file from another folder completely with and without wrapping the %f in quotes. Trying st works correctly but complains "couldn't read from shell: I/O error" when exiting.

What would be perfect would be a variable that could set to detach apps without the need to launch another terminal if possible either globally or on a per app basis.

@leo-arch
Copy link
Owner

Tried with both sakura (3.8.7, AUR) and st (0.8.2) and they both work fine. Have you tried with another terminal, say xterm?

opens some random file from another folder completely with and without wrapping the %f in quotes

This is pretty weird, specially if it works fine when using st (which means that the file to be opened is properly passed to the opening application). Maybe some issue with your sakura version?

What would be perfect would be a variable that could set to detach apps without the need to launch another terminal if possible either globally or on a per app basis.

I'll bear this in mind.

@ErinVoid
Copy link
Author

Thank you

@leo-arch
Copy link
Owner

But the thing is still not working, isn't it? Could you provide more context info (OS, DE/WM, term, shell, clifm version)? I need to reproduce the issue.

@ErinVoid
Copy link
Author

Alpine Linux 3.18 up to date (musl libc)
Sakura 3.8.7-r0
st 0.9-r1
CliFM 1.11-r0
bash 5.2.15-r5

In a folder; type "2" at the prompt, it recognises it being "Show S13E01.mp4", st opens correctly "/my/file/path/show name/Show S13E01" [st -e %f &] whereas Sakura immediately opens "/my/file/path/show/Show S00E01.mp4". It also occurs whatever file is chosen in the selected folder.

Bit of debugging; the requested URI is ""/my/file/path/show name/Show" so the whole folder is enqueued.

There are other posts about Sakura and it not coping with spaces. Wrapping the %f in "" makes no difference. st is fine!

@leo-arch
Copy link
Owner

leo-arch commented Nov 20, 2023

Hey @ErinVoid! I'll try to reproduce the issue, but it is good to know that it seems to be a Sakura bug. However, maybe we can think of some workaround. For the time being, I guess it's better not to rely on Sakura, at least for this specific use case.

Btw, clifm current version is 1.15 (available in Alpine's Edge branch).

@leo-arch
Copy link
Owner

leo-arch commented Nov 20, 2023

Issue reproduced, and yes, the -e option seems to be broken in Sakura since a long time (see this post).

So, if there's nothing else to add regarding our original issue, I guess we can close it.

@ErinVoid
Copy link
Author

If possible, change to a feature request for spawning apps and focus returning to Clifm?

Happy the -e bug is Sakura's.

@leo-arch
Copy link
Owner

What do you mean exactly? Isn't this request already fulfilled by my first comment? True, once an app is spawned in a different window (detached), the focus will change to it, but this is not controlled by clifm, but by the window manager, in which case there's nothing we can do as far as I know.

@ErinVoid
Copy link
Author

The request was for Clifm to open GUI applications as a separate process to allow Clifm to continue to be used without opening additional terminal windows.

@leo-arch
Copy link
Owner

When it comes to GUI apps, all you need to do is to specify the desired application. For example, if you want to open video files with vlc:

X:^video/.*=vlc

This will open vlc on a separate window without requiring a new terminal window (because GUI apps have their own window). Furthermore, the process is independent/detached: close clifm, and even the terminal it is running on, and vlc will continue running. You can also run it in the background (though it doesn't make much difference):

X:^video/.*=vlc %f &

In the case of terminal apps, like mpv, which do not create a new window by themselves, we need to run them on a new terminal window in order to detach it (otherwise, it will be executed on the current terminal window):

X:^video/.*=xterm -e mpv %f &

If this is not what you want, please provide a more concrete example.

@leo-arch
Copy link
Owner

leo-arch commented Dec 4, 2023

@ErinVoid, is it ok to close this issue then?

@ErinVoid
Copy link
Author

ErinVoid commented Dec 7, 2023

Other CLI FMs manage to open mpv without a terminal. Going to close anyway.

@ErinVoid ErinVoid closed this as completed Dec 7, 2023
@leo-arch
Copy link
Owner

leo-arch commented Dec 7, 2023

You can try silencing both STDERR and STDOUT, as follows:

X:^video/.*=mpv %f !EO &

As an alternative, mpv provides a --no-terminal command line switch which can be useful in this case. Try this:

X:^video/.*=mpv --no-terminal %f &

Please give it a shot and tell me if it's ok now.

@leo-arch leo-arch reopened this Dec 7, 2023
@leo-arch
Copy link
Owner

@ErinVoid, have you tried this? Does it work for you?

@leo-arch
Copy link
Owner

@ErinVoid, does the above solution work as expected?

@leo-arch
Copy link
Owner

Happy the -e bug is Sakura's

Bug fixed upstream.

@LinArcX
Copy link

LinArcX commented Apr 2, 2024

I have this issue. I tried: X:^video/.*=mpv --no-terminal %f &. mpv is running, yes. but the terminal is freezing. even Ctrl+C doesn't work. I need to press Ctrl+z to get out of it. I have this impression that & doesn't work properly in clifm.

@leo-arch
Copy link
Owner

leo-arch commented Apr 2, 2024

@LinArcX , I cannot reproduce this issue (tried this rule with Openbox/i3 and alacritty/xterm/lxterminal, no issue). Could you provide more context information (clifm version, terminal, desktop environment/window manager)?

@LinArcX
Copy link

LinArcX commented Apr 2, 2024

OS: VoidLinux
Clifm: v1.18(https://github.com/search?q=repo%3Avoid-linux%2Fvoid-packages%20clifm&type=code)
Terminal Emulator: wezterm
Windows Manager: dwm

@leo-arch
Copy link
Owner

leo-arch commented Apr 3, 2024

Tried with wezterm. Still nothing.

The only way I've found to reproduce this issue (or at least something similar) is having the current terminal window maximized, in which case the video is certainly reproduced, but in a window hidden by the currently used one.

Please try with a different terminal (to discard a terminal-specific issue) and with a different video application (to discard an mpv-specific issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants