Skip to content

Show mpv window in the center of the display when it is in floating mode (i3wm)

License

Notifications You must be signed in to change notification settings

mdnghtman/mpv-i3-floating-centered

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

mpv-i3-floating-centered

mpv-i3-floating-centered is a script for mpv written in Lua. Its purpose is to center a floating mpv window in the i3 window manager.

To achieve this it will:

  • Get the window id of the mpv process.
  • Check if it's in floating mode
  • Tell i3-msg to center the window by its window id.

Dependencies

  • xdotool
  • xprop

Install via your systems package manager.

Install

Place the file mpv-i3-floating-centered.lua in your ~/.config/mpv/scripts/ directory, creating it if needed, and that's it. Run mpv as you normally would and you're now using it.

Recommended settings

Though the Lua script is all you need, combining it with two more settings is pretty great.

You can use the autofit setting in ~/.config/mpv/mpv.conf to enforce a window size. For example on a 27in 2560x1440 display enforcing a size of 1920x1080 works well:

autofit=1920x1080

It doesn't modify aspect ratio, only increasing or decreasing the window size within the specified bounds. To use the entire display just toggle fullscreen. This option can also be specified by a percentage, read more about it from the mpv manual: https://mpv.io/manual/stable/

Lastly, in your i3 config file: ~/.config/i3/config enable floating mpv windows by default:

for_window [class="mpv"] floating enable

Save and reload i3 with $mod+Shift+r

About

Show mpv window in the center of the display when it is in floating mode (i3wm)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages