Hari Sekhon - MPV-Scripts

June 15, 2026 ยท View on GitHub

GitHub stars GitHub forks LineCount Cocomo License My LinkedIn GitHub Last Commit

Codacy CodeFactor Quality Gate Status Maintainability Rating Reliability Rating Security Rating

CI Builds Overview Linux Mac

Mac Homebrew Alpine CentOS Debian Fedora Redhat Rocky Ubuntu

Repo on GitHub Repo on GitLab Repo on Azure DevOps Repo on BitBucket

Markdown Validation Kics Grype Semgrep Semgrep Cloud SonarCloud Trivy

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

https://mpv.io/

:octocat: mpv-player/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 variable MPV_SPEED is set
  • maximize-window.lua - automatically maximizes the window without entering fullscreen mode (which is annoyingly slow on Macs due to fancy effects).
    • adds key binding Shift+M to toggle maximize / unmaximize
  • delete-on-eof.lua - delete a video after completed playback if environment variable MPV_DELETE_ON_EOF is 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.sh script
  • 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

Knowledge-Base Diagrams-as-Code

DevOps Code

DevOps-Bash-tools DevOps-Python-tools DevOps-Perl-tools DevOps-Golang-tools

Containerization

Kubernetes-configs Dockerfiles

CI/CD

GitHub-Actions Jenkins

Databases - DBA - SQL

SQL-scripts

DevOps Reloaded

HAProxy-configs Terraform Packer Ansible Environments

Monitoring

Nagios-Plugins Nagios-Plugin-Kafka Prometheus

Templates

Templates Template-repo

Desktop

TamperMonkey Hammerspoon MPV-Scripts

Spotify

Spotify-tools Spotify-playlists

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.