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.
- 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
- Windows:
%AppData%\mpv\scripts\ - Linux:
~/.config/mpv/scripts/
Place single_instance.lua into the scripts folder.
MPV will automatically detect the script at next launch.
The script:
- Checks whether an IPC server is already active.
- If not found β becomes the main MPV instance and creates one.
- If found β becomes a secondary instance, sends its file path via IPC, and exits.
- Windows:
\\.\pipe\mpvsocket - Linux:
/tmp/mpvsocket
- 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.
The repo also contains the single_instance.lua file with full source code.
MIT License