8000 GitHub - ed9w2in6/uiina: Using single-instance of IINA when launching through the command line
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ed9w2in6/uiina

Repository files navigation

uiina

About

Badges

https://img.shields.io/github/v/release/ed9w2in6/uiina.svg https://github.com/ed9w2in6/uiina/actions/workflows/build.yml/badge.svg https://img.shields.io/badge/Python-3776AB.svg?logo=python&logoColor=fff https://img.shields.io/badge/macOS-000000.svg?logo=apple&logoColor=F0F0F0 https://img.shields.io/badge/Homebrew-FBB040.svg?logo=homebrew&logoColor=fff https://img.shields.io/badge/Nix-5277C3.svg?logo=nixos&logoColor=fff

Origins

This repository contains the CLI tool uiina, modified from this script from mpv’s repository at Github. Also a good oppourtunity for me to learn python project build based on uv2nix + nix flakes.

Last modified: [2025-05-08 Thu]

uiina --help
Usage: uiina [option] [target ...]

    options:
        -h | --help           Show this help.
        -v | --verbose        Be verbose.
        -V | --version        Print version info then exit.

    target ...:
       The target(s) to be opened by uiina.
       They can be paths, or URLs.
       To read from stdin, give a single parameter "-" and nothing else.

    Inspect the python script for a more detailed explaination.

Differences with umpv

better functions signatures, variables names, and CLI options

All mentions of mpv have been replaced with iina where applicable.

It should be noted that IINA will NOT quite automatically after all files are played. The way mpv options are via iina is also different:

iina --help | head -n 10

keep-alive when new socket for auto cleanup on quit

Since commit dfbd60f umpv had changed to NOT wait for quit even for new socket / pipe.

However, due to uiina’s auto cleanup feature we DO need it to keep alive and clean up on quit.

read from stdin and using URL

unlike mpv we allow reading from stdin. We also accepts URLs too due to IINA’s builtin yt-dlp.

socket directory

You can configure the socket directory with a environment variable.

These are accepted, in order of precedence:

  • UIINA_SOCKET_DIR
  • XDG_RUNTIME_DIR
  • HOME
    • in uiina we take this from Path.home(), unlike umpv which relies on env var.
  • TMPDIR

Shared features

Single instance

This script ensures that only one instance of IINA is used.

If invoked via the command line, it will attempt to append files to the playlist of an already running IINA instance but only if that instance was started with the uiina command, which can be detected by socket / pipe existence. Any other IINA processes remain unaffected.

If an target argument is invalid, IINA will quit with a non-zero exit code.

If no good IINA running, that is no socket / pipe file, they will be created and a fresh IINA instance will be launch. To avoid cluttering logs (notably ~/.xsession-errors or, on macOS, stdout/stderr), it deliberately suppresses output.

Custom Configuration

You may define a custom IINA (originally MPV for umpv) binary path and options using some appropriate environment variable.

This variable is split on whitespace:

  • the first element specifies the IINA binary’s path
  • any subsequent items are options applied only when the script initiates IINA
    • If IINA is already running, these settings are ignored

How to use

Using nix

Try it out

nix run github:ed9w2in6/uiina#default

imperative install :: Not recommended

Run any of these:

  • nix-env -iA github:ed9w2in6/uiina#default
  • nix profile install github:ed9w2in6/uiina#default

using nix flakes

Something like this in your nix-darwin / home-manager flake.

{
  description = "Example configuration with uiina installed";

  inputs = {
    # use your preferred nixpkgs channel here
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nix-darwin.url = "github:nix-darwin/nix-darwin";
    home-manager.url = "github:nix-community/home-manager";

    # add the uiina flake as an input
    uiina-flake.url = "github:ed9w2in6/uiina";
  };

  outputs =
    {
      self,
      nixpkgs,
      nix-darwin,
      home-manager,
      uiina-flake,
    }:
    let
      username = "my-name";
      homeDirectory = "/Users/${username}";
      system = "x86_64-darwin"; # [2025-05-08]: only "x86_64-darwin" for now, can easily add the "aarch64-darwin" later
      pkgs = import nixpkgs { inherit system; };
      uiina = uiina-flake.packages.x86_64-darwin.default;
    in
    {
      darwinConfigurations."my-hostname" = nix-darwin.lib.darwinSystem {
        inherit system;
        modules = [
          (
            { config, pkgs, ... }:
            {
              environment.systemPackages = with pkgs; [
                uiina
              ];
            }
          )
          home-manager.darwinModules.home-manager
          {
            home-manager = {
              users."${username}" = {
                home = (
                  {
                    pkgs,
                    lib,
                    # config,
                    ...
                  }:
                  {
                    # WARNING: you probably should NOT change yours
                    stateVersion = "25.05"; # this is just an example
                    # WARNING: you probably should NOT change yours

                    inherit username homeDirectory;
                    packages = with pkgs; [
                      uiina
                    ];
                  }
                );
              };
            };
          }
        ];
      };
    };
}

From release

After downloading the uiina binary

  • Verify its checksum (e.g. sha256sum --check sha256sum.txt)
  • Move the uiina binary to your desired location
  • Make your desired location is under $PATH

Other notes

Licensing follows mpv

As this software is a derivative work of mpv, it is licensed with the same terms.

If there are any difference in the licensing terms, consider that a result of error. Please contact for any licensing error and refer to the mpv-player repository as the authorative source.

About

Using single-instance of IINA when launching through the command line

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0