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

Opening a file with mimeapp creates a child process. #194

Closed
kaldyr opened this issue Sep 21, 2023 · 16 comments · Fixed by #216, #229 or #290
Closed

Opening a file with mimeapp creates a child process. #194

kaldyr opened this issue Sep 21, 2023 · 16 comments · Fixed by #216, #229 or #290
Labels
enhancement New feature or request waiting on op Waiting for more information from the original poster

Comments

@kaldyr
Copy link

kaldyr commented Sep 21, 2023

When opening a file (with "o") with a mimeapp (zathura or any other application), the resulting process is a child process of yazi. Closing yazi will also close the child process. It would be nice to pop into yazi, open a file, and close yazi without also closing the spawned process.

@sxyazi
Copy link
Owner

sxyazi commented Sep 23, 2023

Done by #216, please give it a try!

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Sep 23, 2023
@kaldyr
Copy link
Author

kaldyr commented Sep 24, 2023

Just compiled from the pr-5202b9db branch and set the orphan = true and it works perfectly! Thanks!

@kaldyr kaldyr closed this as completed Sep 24, 2023
@sxyazi
Copy link
Owner

sxyazi commented Sep 24, 2023

Thank you for testing, merged!

@Brixy
Copy link
Contributor

Brixy commented Sep 29, 2023

Hi guys, I don’t want to clutter this closed thread; but orphan = true has no effect at all for me. I compiled yazi from the current main branch and from the corresponding commit.

Setup: Void Linux, glibc, wayland, river.

Also roughly tested yazi under xorg + i3 to ensure that wayland does not cause the problem.

Is this a yazi bug on linux, and is there anything I can do to help you test this? Am I just missing anyething?

Thanks again for yazi and your excellent work!

@sxyazi
Copy link
Owner

sxyazi commented Sep 29, 2023

Hi @Brixy, could you please paste your opener configuration here, and the steps you followed? This will help me understand what happened.

@kaldyr
Copy link
Author

kaldyr commented Sep 29, 2023

It may be worth adding more information to the --version flag to figure out specifically which build is currently being executed.

@kaldyr
Copy link
Author

kaldyr commented Sep 30, 2023

Just confirmed working on 492929a.

in my flake.nix inputs:

yazi.url = "github:sxyazi/yazi";

in my flake.lock (just verifying version number):

    "yazi": {
      "inputs": {
        "devenv": "devenv",
        "flake-utils": "flake-utils_2",
        "nixpkgs": "nixpkgs_3"
      },
      "locked": {
        "lastModified": 1695947466,
        "narHash": "sha256-IBo7OYKT45FBvAdAj27yS1tIzOBAZThfXdaPg+XIdV8=",
        "owner": "sxyazi",
        "repo": "yazi",
        "rev": "492929a0b82f593c886fce3c533575b96489d1ab",
        "type": "github"
      },
      "original": {
        "owner": "sxyazi",
        "repo": "yazi",
        "type": "github"
      }
    }

in my home-manager.nix:

    programs.yazi = {
      enable = true;
      package = inputs.yazi.packages.${pkgs.system}.yazi;
      enableFishIntegration = true;
      settings = {
        manager = {
          sort_by = "natural";
          sort_reverse = false;
          sort_dir_first = true;
          show_hidden = false;
          show_symlink = true;
        };
        opener = {
          audio = [{
            exec = "clapper \"$@\"";
            orphan = true;
          }];
          video = [{
            exec = "clapper \"$@\"";
            orphan = true;
          }];
          folder = [{
            exec = "$EDITOR \"$@\"";
            block = true;
          }];
          text = [{
            exec = "$EDITOR \"$@\"";
            block = true;
          }];
          fallback = [
            {
              exec = "xdg-open \"$@\"";
              orphan = true;
            }
            {
              exec = "$EDITOR \"$@\"";
              block = true;
            }
          ];
        };
      };
    };

which generates the following ~/.config/yazi/yazi.toml file:

[manager]
show_hidden = false
show_symlink = true
sort_by = "natural"
sort_dir_first = true
sort_reverse = false

[opener]
[[opener.audio]]
exec = "clapper \"$@\""
orphan = true

[[opener.fallback]]
exec = "xdg-open \"$@\""
orphan = true

[[opener.fallback]]
block = true
exec = "$EDITOR \"$@\""

[[opener.folder]]
block = true
exec = "$EDITOR \"$@\""

[[opener.text]]
block = true
exec = "$EDITOR \"$@\""

[[opener.video]]
exec = "clapper \"$@\""
orphan = true

@Brixy
Copy link
Contributor

Brixy commented Sep 30, 2023

Thanks a lot for your replies!

Here’s my steps to reproduce:

I just deleted my target/ folder and compiled from the current commit. Functions newer than the the orphan functionality work, so the newest version of yazi should be compiled correctly.

Moreover, I switched back to the default settings and just edited a single line for the video opener in yazi.toml:

{ exec = 'mpv "$@"', orphan = true },

When I open a video it seems to be run as a child process anyway, and it is listed in the list of tasks (w).

As soon as yazi is closed (q, ^q or through the window manager) the mpv window is closed, too.

Thanks a lot for investigating!

BTW: Just noticed that undo does not seem to work, either. Please let me know if I should open an issue for this.

@sxyazi
Copy link
Owner

sxyazi commented Sep 30, 2023

I followed the steps above to reproduce the issue and found that the reason is that mpv is not only a GUI program but also a CLI.

It retrieves stdout while displaying the GUI, and when Yazi exits, stdout becomes inactive, causing mpv to exit as well.

Although mpv --no-terminal can make it work, in case there are similar programs, I have created a PR to fix it. Please give it a try. #229

@sxyazi
Copy link
Owner

sxyazi commented Sep 30, 2023

It may be worth adding more information to the --version flag to figure out specifically which build is currently being executed.

Seems like this is what #206 to do

@Brixy
Copy link
Contributor

Brixy commented Sep 30, 2023

Excellent. Can confirm that #229 works perfectly—with mpv and “real” GUIs (tested with abiword).

So mpv was either the best or worst example ;-)

Thank you very much for all your work!

Just as a side note: When yazi is killed by just closing its window using the window manager (river) the mpv window is closed, too. That’s no problem at all. Yet, when an nnn window is closed this way the video window remains open.

@sxyazi
Copy link
Owner

sxyazi commented Sep 30, 2023

When yazi is killed by just closing its window using the window manager (river) the mpv window is closed, too.

I've tried for a long time but couldn't fix it. I've decided to just leave it here. If anyone knows the reason, please let me know :)

BTW: Just noticed that undo does not seem to work, either. Please let me know if I should open an issue for this.

I think what you're asked is the undo function in the Vi-like input component. https://yazi-rs.github.io/docs/usage/configuration/keymap#normal-mode

@Brixy
Copy link
Contributor

Brixy commented Sep 30, 2023

I think what you're asked is the undo function in the Vi-like input component.

Yes, sorry. I did not investigate here. I thought it was possible to e.g. undo file deletion or mass renaming.

I've tried for a long time but couldn't fix it. I've decided to just leave it here. If anyone knows the reason, please let me know :)

Thank you very much for investigating!!

@sxyazi
Copy link
Owner

sxyazi commented Oct 20, 2023

Just as a side note: When yazi is killed by just closing its window using the window manager (river) the mpv window is closed, too. That’s no problem at all. Yet, when an nnn window is closed this way the video window remains open.

Hi @Brixy, I have revisited it and found a solution. A PR is created should fix it: #290

@Brixy
Copy link
Contributor

Brixy commented Oct 20, 2023

I have revisited it and found a solution. A PR is created should fix it: #290

Thank you very much for your brilliant work! I can confirm that this works.


BTW: I found a use case where this is important:

If you opened yazi ‘directly’ e.g. using the following command in a window manager, closing yazi using q would also have killed the terminal emulator and yazi’s orphans.

riverctl map normal Super Y spawn "foot -D $HOME -e yazi"

With your changes everything works perfectly. Thanks a lot for this!

Copy link

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request waiting on op Waiting for more information from the original poster
Projects
None yet
3 participants