Mpv scripts not working when mpv called from another program

I have installed mpv including a couple of scripts using home-manager. Everything works well when running mpv from the terminal. However, I use a script called ytfzf that allows me to play youtube videos using mpv, and in this case when mpv is run, I can see that the scripts are not being run.

How can I ensure that ytfzf calls mpv with the scripts I installed?

2 Likes

Does anyone have any insight?

I really want mpv to use the mpris script even when mpv is being called by other apps such as ytfzf.

This is still an issue and has not been been solved by any recent updates. Does anyone have any insights or ideas?

Hello,

See in my opinion you should replace when called from ytfzf. Here’s what you can do:

Check Settings: Make sure all necessary settings are in place for the scripts to run smoothly when ytfzf calls MPV.

Verify Script Paths: Double-check that the scripts are in a folder that ytfzf can access.

Permissions: Ensure the scripts have the right permissions to execute.

Debugging: Add some debug lines to see if the scripts are running at all when called by ytfzf.

Shell Configurations: If needed, set up any specific shell configurations required for the scripts to work.

Integration: Look into how ytfzf interacts with MPV to see if there are any specific instructions for using custom scripts.

By going through these steps, you should be able to figure out why the scripts aren’t working as expected.
hope the above will be helpful.

1 Like

I guess you need to override ytfzf’s mpv to have the same plugins:

Home-manager

# home.nix
{ pkgs, ... }:
let
  mpvScripts = with pkgs.mpvScripts; [
    mpris
    thumbfast
  ];
in
{
  home.packages = with pkgs; [
    (ytfzf.override {
      mpv = mpv.override {
        scripts = mpvScripts;
      };
    })
  ];

  programs.mpv = {
    enable = true;
    scripts = mpvScripts;
  };
}

Overlays

# configuration.nix
{pkgs, ...}:
let
  mpvScripts = with pkgs.mpvScripts; [
    mpris
    thumbfast
  ];
in
{
  nixpkgs.overlays = [
    (final: prev: { mpv = prev.mpv.override { scripts = mpvScripts; }; })
    (final: prev: { ytfzf = prev.ytfzf.override { mpv = final.mpv; }; })
  ];

  environment.systemPackages = with pkgs; [
    mpv
    ytfzf
  ];
}
1 Like

The problem here is that the plugins are not installed manually, so the mpv used by ytfzf is not the same as the one created by home-manager/overlays.

Maybe there are better ways to fix this, but I’ve tried the methods above and they both worked.

2 Likes

Awesome. I tried your home-manager solution and it worked just great. Nice to have mpris working!

In your example, I can see that you included thumbfast. How do you get the thumbnails to appear in mpv?

1 Like

To get thumbfast working you just have to install a UI plugin that supports it. I like to have a minimal UI as close as possible to the mpv default, that’s why I installed osc.lua and since I don’t think it’s in the nixpkgs (a package for the future, perhaps? :grin:), I just added it manually to ~/.config/mpv/scripts and it’s been working without any issues.

1 Like

Gotcha. Got it working. Also giving uosc a try. It looks nice and is also quite minimal.

1 Like