diff options
| author | Mike Vink <ivi@vinkies.net> | 2025-06-25 11:34:08 +0800 |
|---|---|---|
| committer | Mike Vink <ivi@vinkies.net> | 2025-06-25 11:34:33 +0800 |
| commit | 49c4a121cc6ca89a79eb55149719edd5ae08dffe (patch) | |
| tree | 27ded4822e895f6021e1937ee11bc553d0ed9548 /.config/mpv | |
| parent | eb827a945cb7035859a47ca243559659d48d87dc (diff) | |
music and dtach fix
Diffstat (limited to '.config/mpv')
| -rw-r--r-- | .config/mpv/input.conf | 5 | ||||
| -rw-r--r-- | .config/mpv/script_modules/mpvSockets/mpvSockets.lua | 36 | ||||
| -rw-r--r-- | .config/mpv/scripts/modules.lua | 3 |
3 files changed, 44 insertions, 0 deletions
diff --git a/.config/mpv/input.conf b/.config/mpv/input.conf new file mode 100644 index 0000000..d614b15 --- /dev/null +++ b/.config/mpv/input.conf @@ -0,0 +1,5 @@ +l seek 5 +h seek -5 +j seek -60 +k seek 60 +S cycle sub diff --git a/.config/mpv/script_modules/mpvSockets/mpvSockets.lua b/.config/mpv/script_modules/mpvSockets/mpvSockets.lua new file mode 100644 index 0000000..df8d078 --- /dev/null +++ b/.config/mpv/script_modules/mpvSockets/mpvSockets.lua @@ -0,0 +1,36 @@ +-- mpvSockets, one socket per instance, removes socket on exit + +local utils = require 'mp.utils' + +local function get_temp_path() + local directory_seperator = package.config:match("([^\n]*)\n?") + local example_temp_file_path = os.tmpname() + + -- remove generated temp file + pcall(os.remove, example_temp_file_path) + + local seperator_idx = example_temp_file_path:reverse():find(directory_seperator) + local temp_path_length = #example_temp_file_path - seperator_idx + + return example_temp_file_path:sub(1, temp_path_length) +end + +tempDir = get_temp_path() + +function join_paths(...) + local arg={...} + path = "" + for i,v in ipairs(arg) do + path = utils.join_path(path, tostring(v)) + end + return path; +end + +ppid = utils.getpid() +os.execute("mkdir " .. join_paths(tempDir, "mpvSockets") .. " 2>/dev/null") +mp.set_property("options/input-ipc-server", join_paths(tempDir, "mpvSockets", ppid)) + +function shutdown_handler() + os.remove(join_paths(tempDir, "mpvSockets", ppid)) +end +mp.register_event("shutdown", shutdown_handler) diff --git a/.config/mpv/scripts/modules.lua b/.config/mpv/scripts/modules.lua new file mode 100644 index 0000000..703f372 --- /dev/null +++ b/.config/mpv/scripts/modules.lua @@ -0,0 +1,3 @@ +local mpv_config_dir_path = require("mp").command_native({"expand-path", "~~/"}) +function load(relative_path) dofile(mpv_config_dir_path .. "/script_modules/" .. relative_path) end +load("mpvSockets/mpvSockets.lua") |
