How to force mpv to always stay on top?
Forcing the mpv media player to stay pinned above all other desktop windows is entirely possible and can be accomplished permanently through a configuration file, temporarily via a command-line flag, or instantly using a keyboard shortcut during playback. This brief guide outlines each method to help you keep your video window visible regardless of which other applications you focus on.
Method 1: Modify the mpv Configuration File (Permanent)
To ensure mpv always launches in “always on top” mode without typing a command every time, you can add a single line to your permanent configuration file.
- Locate or create your
mpv.conffile based on your operating system:
- Windows:
C:\Users\Username\AppData\Roaming\mpv\mpv.conf(or inside the same folder as yourmpv.exeif using a portable installation). - Linux/macOS:
~/.config/mpv/mpv.conf
- Open
mpv.confin any plain text editor. - Add the following line on its own line:
ontop=yes
- Save and close the file.
Method 2: Use the Keyboard Shortcut (On-the-Fly)
If you only want a window to stay on top occasionally, you can toggle the setting dynamically using your keyboard during active playback.
- Press
Shift + T(capitalT) while the mpv window is active.
An on-screen display (OSD) message reading “Stay on top: yes” or “Stay on top: no” will appear briefly to confirm the status change.
Method 3: Use the Command-Line Terminal (Temporary)
If you are launching a video directly from your system terminal or an automation script, you can pass a flag to tell that specific instance of mpv to stay on top.
mpv --ontop video_file.mp4Note for Linux Wayland Users: If you are running a Linux desktop environment using the Wayland display server (such as default GNOME), the standard
--ontopoption may be blocked by your compositor’s protocol security. IfShift + Tor the config file fails to pin the window, you will need to right-click the window title bar or useAlt + Spaceto manually select the system-level “Always on Top” option.