Skip to content

Add support for running script as a directory #133

@Commander07

Description

@Commander07

Adding support for running the script in/as a directory can make script management easier for the user while still allowing for installation/usage outside a directory without any changes to the current installation procedure. More information about script locations are available in the mpv documentation.

Advantages

  • Easy updating for end users. By having support for the script to be loaded as a directory you would be able to download it via git clone and could even use it as a submodule for use in a version controlled mpv config. This would mean no update conflicts and easy rollbacks & modifications for the user.
  • Easier sharing of mpv configs including the script. With the possibility of loading it as a directory, people can include the script via git submodule which allows both config publisher and potential user to more easily see differences between version included in the config and upstream. Git submodule example repo.

Problems

  • The font would be located within the script directory which means an alternate font loading method or workaround would be required (not sure if this is possible).
  • Extra scripts would always be downloaded but never activated. To fix this a config would need to be created which toggles on and off the require statements in main.lua

Implementation

Aside from the font loading issue implementation would only require adding a small main.lua file which requires the existing script and configurably requires the extra scripts. So something like this:

-- main.lua
require('modernz')

local opt = require("mp.options")
local extras = {
    pause_indicator_lite = false,
}
opt.read_options(extras, "modernz-extras")

if extras.pause_indicator_lite then
    require('extras.pause-indicator-lite.pause_indicator_lite')
end

Summary

If loading the font from the script directory is possible then it's possible to support the script running as/in a directory with just the above code snippet and the alternate font loading method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions