Skip to content

Commit 23636da

Browse files
committed
Make the kill behaviour configurable
1 parent 8c0e352 commit 23636da

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

notify_media.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ delayed_sec=3
1010
# Name of mpv's input-ipc-server (defaults to mpvsocket_{pid}), it shall be useful when multiple scripts set up the IPC socket for controls.
1111
# String "{pid}" in this config value will be automatically convert to the ID of mpv process to prevent conflicts between multiple instances.
1212
socket_name=mpvsocket_{pid}
13+
# Should we kill MPVMediaControl when mpv exits, as sometimes the program won't exit properly with mpv
14+
kill_mc=no

notify_media.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ local o = {
1212
delayed_sec = 3,
1313
-- Name of mpv's input-ipc-server (defaults to mpvsocket_{pid}), string "{pid}" in the value will be automatically replaced with the ID of mpv process
1414
socket_name = "mpvsocket_{pid}",
15+
-- Should we kill MPVMediaControl when mpv exits, as sometimes the program won't exit properly with mpv
16+
kill_mc = false,
1517
}
1618

1719
opt.read_options(o, "notify_media")
@@ -264,12 +266,14 @@ function on_quit()
264266
end
265267
write_to_socket("^[setQuit](pid=" .. pid .. ")(quit=true)(socket_name=" .. mpv_socket_name .. ")$")
266268

267-
-- Force kill MPVMediaControl.exe
268-
mp.command_native({
269-
name = "subprocess",
270-
playback_only = false,
271-
args = {"taskkill", "/F", "/IM", "MPVMediaControl.exe"},
272-
})
269+
if o.kill_mc then
270+
-- Force kill MPVMediaControl.exe
271+
mp.command_native({
272+
name = "subprocess",
273+
playback_only = false,
274+
args = {"taskkill", "/F", "/IM", "MPVMediaControl.exe"},
275+
})
276+
end
273277
end
274278

275279
mp.register_event("shutdown", on_quit)

0 commit comments

Comments
 (0)