Fix MPV menu: resolve Lua syntax error and enhance logging

- Remove extra 'end)' that caused '<eof>' expected syntax error at line 2834
- Add comprehensive logging to M.show_menu() with [MENU] prefix
- Add logging wrappers to keybindings (m and mbtn_right)
- Implement fallback menu opening methods (commandv and command)
- Fix audio-display mpv.conf setting to 'no' (was invalid 'yes')
This commit is contained in:
2026-02-03 18:26:36 -08:00
parent cc19403087
commit 81b11a8517
6 changed files with 124 additions and 26 deletions

View File

@@ -870,13 +870,35 @@ class MPVIPCClient:
if not self.connect():
raise MPVIPCError("Not connected")
if self.is_windows:
pipe = cast(BinaryIO, self.sock)
pipe.write(payload.encode("utf-8"))
pipe.flush()
else:
sock_obj = cast(socket.socket, self.sock)
sock_obj.sendall(payload.encode("utf-8"))
try:
if self.is_windows:
pipe = cast(BinaryIO, self.sock)
pipe.write(payload.encode("utf-8"))
pipe.flush()
else:
sock_obj = cast(socket.socket, self.sock)
sock_obj.sendall(payload.encode("utf-8"))
except (OSError, IOError, BrokenPipeError) as exc:
# Pipe became invalid (disconnected, corrupted, etc.).
# Disconnect and attempt one reconnection.
if not self.silent:
debug(f"Pipe write failed: {exc}; attempting reconnect")
self.disconnect()
if self.connect():
# Retry once after reconnect
try:
if self.is_windows:
pipe = cast(BinaryIO, self.sock)
pipe.write(payload.encode("utf-8"))
pipe.flush()
else:
sock_obj = cast(socket.socket, self.sock)
sock_obj.sendall(payload.encode("utf-8"))
except (OSError, IOError, BrokenPipeError) as retry_exc:
self.disconnect()
raise MPVIPCError(f"Pipe write failed after reconnect: {retry_exc}") from retry_exc
else:
raise MPVIPCError("Failed to reconnect after pipe write error") from exc
def _readline(self, *, timeout: Optional[float] = None) -> Optional[bytes]:
if not self.sock:
@@ -890,7 +912,11 @@ class MPVIPCClient:
try:
pipe = cast(BinaryIO, self.sock)
return pipe.readline()
except (OSError, IOError):
except (OSError, IOError, BrokenPipeError) as exc:
# Pipe error; try to reconnect once
if not self.silent:
debug(f"Pipe readline failed: {exc}")
self.disconnect()
return None
# Unix: buffer until newline.