Skip to content

This repo contains a Lua script for MPV that forces all secondary MPV launches to send the file to the main MPV window instead of opening multiple players.

Notifications You must be signed in to change notification settings

ashik4u/MPV-Single-Instance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MPV Single Instance Script

This repo contains a Lua script for MPV that forces all secondary MPV launches to send the file to the main MPV window instead of opening multiple players.

πŸ“Œ Features

  • Ensures # MPV Single Instance Script runs as a single instance
  • Secondary launches forward file paths to the main instance
  • Uses IPC pipes/sockets for communication
  • Supports Windows and Linux
  • Automatically detects whether the instance is main or secondary

πŸ“‚ Installation

1. Create your MPV scripts folder

  • Windows: %AppData%\mpv\scripts\
  • Linux: ~/.config/mpv/scripts/

2. Copy the script

Place single_instance.lua into the scripts folder.

3. Done!

MPV will automatically detect the script at next launch.

πŸ“˜ How it works

The script:

  1. Checks whether an IPC server is already active.
  2. If not found β†’ becomes the main MPV instance and creates one.
  3. If found β†’ becomes a secondary instance, sends its file path via IPC, and exits.

πŸ›  IPC Socket Paths

  • Windows: \\.\pipe\mpvsocket
  • Linux: /tmp/mpvsocket

▢️ Example behavior

  • You open a file β†’ MPV starts normally.
  • You double-click another video β†’ the second MPV launches but detects main instance β†’ sends the new file to the main MPV β†’ quits.

πŸ“œ Script included

The repo also contains the single_instance.lua file with full source code.

πŸ“„ License

MIT License

About

This repo contains a Lua script for MPV that forces all secondary MPV launches to send the file to the main MPV window instead of opening multiple players.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages