Hari Sekhon - MPV-Scripts
June 15, 2026 ยท View on GitHub
Summary
Lua code to control the behaviour of the excellent open source mpv video player.
See the scripts/ directory for the Lua code to control MPV.
MPV
Setup
Create the github and local config dirs if they don't already exist:
mkdir -p -v ~/github ~/.config
Clone this repo:
git clone https://github.com/HariSekhon/MPV-Scripts ~/github/mpvscripts
Symlink to the location MPV expects to find its config and scripts:
ln -svf ~/github/mpvscripts ~/.config/mpv
(if ~/.config/mpv already exists you will need to move it out the way first otherwise it will symlink into a subdirectory and won't pick up the scripts)
MPV Config
mpv.conf- MPV settings such as saving position on quit
MPV Scripts
Under the scripts/ directory:
speed.lua- sets playback speed if environment variableMPV_SPEEDis setmaximize-window.lua- automatically maximizes the window without entering fullscreen mode (which is annoyingly slow on Macs due to fancy effects).- adds key binding
Shift+Mto toggle maximize / unmaximize
- adds key binding
delete-on-eof.lua- delete a video after completed playback if environment variableMPV_DELETE_ON_EOFis set to any value- for those videos you downloaded to only watch once
- this automatic cleanup helps to save space and reduces you needing to manually delete the video
- written to automatically clean out YouTube videos downloaded using my
DevOps-Bash-tools repo's
youtube_download_video.shscript
resume-conditions.lua- only resume videos that:- are at least 10 minutes long
- have been playing for at least 5 minutes
- have a certain file extension
- are under a specific directory tree
The environment variables above such as MPV_SPEED and MPV_DELETE_ON_EOF
are useful when used with direnv
for specific video directories
(eg. I always watch all YouTube videos at double speed and delete them after one complete play).
Migrated from :octocat: DevOps-Bash-tools repo.
Related Docs:
:octocat: Knowledge-Base - Lua page
:octocat: Knowledge-Base - MPV page
More Core Repos
Knowledge
DevOps Code
Containerization
CI/CD
Databases - DBA - SQL
DevOps Reloaded
Monitoring
Templates
Desktop
Spotify
The rest of my original source repos are here.
Pre-built Docker images are available on my DockerHub and can be re-generated using the my Dockerfiles repo.