Skip to content

Instantly share code, notes, and snippets.

@sephid86
Forked from blackarcher21/remember-volume.lua
Last active August 23, 2023 12:47
Show Gist options
  • Save sephid86/f5b1e50e8428016876ea708309b768db to your computer and use it in GitHub Desktop.
Save sephid86/f5b1e50e8428016876ea708309b768db to your computer and use it in GitHub Desktop.
mpv script - remember audio volume
local filepath = mp.command_native({"expand-path", "~/mpv_volume"})
local loadfile = io.open(filepath, "r")
if loadfile then
set_volume = string.sub(loadfile:read(), 8)
loadfile:close()
mp.set_property_number("volume", set_volume)
end
mp.register_event("shutdown",
function()
local savefile = io.open(filepath, "w+")
savefile:write("volume=" .. mp.get_property("volume"), "\n")
savefile:close()
end
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment