Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions manim/_config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class MyScene(Scene): ...
"zero_pad",
"force_window",
"no_latex_cleanup",
"preview_command",
}

def __init__(self) -> None:
Expand Down Expand Up @@ -767,6 +768,7 @@ def digest_args(self, args: argparse.Namespace) -> Self:
"force_window",
"dry_run",
"no_latex_cleanup",
"preview_command",
]:
if hasattr(args, key):
attr = getattr(args, key)
Expand Down Expand Up @@ -1016,6 +1018,14 @@ def no_latex_cleanup(self) -> bool:
def no_latex_cleanup(self, value: bool) -> None:
self._set_boolean("no_latex_cleanup", value)

@property
def preview_command(self) -> str:
return self._d["preview_command"]

@preview_command.setter
def preview_command(self, value: str) -> None:
self._set_str("preview_command", value)

@property
def verbosity(self) -> str:
"""Logger verbosity; "DEBUG", "INFO", "WARNING", "ERROR", or "CRITICAL" (-v)."""
Expand Down
5 changes: 5 additions & 0 deletions manim/cli/render/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ def validate_gui_location(ctx, param, value):
help="Prevents deletion of .aux, .dvi, and .log files produced by Tex and MathTex.",
default=False,
),
option(
"--preview_command",
help="The command used to preview the output file (for example vlc for video files)",
default="",
),
)
8 changes: 6 additions & 2 deletions manim/utils/file_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from manim import __version__, config, logger

from .. import console
from .. import config, console


def is_mp4_format() -> bool:
Expand Down Expand Up @@ -204,8 +204,12 @@ def open_file(file_path, in_browser=False):
commands = ["open"] if not in_browser else ["open", "-R"]
else:
raise OSError("Unable to identify your operating system...")

# check after so that file path is set correctly
if config.preview_command:
commands = [config.preview_command]
commands.append(file_path)
sp.Popen(commands)
sp.run(commands)


def open_media_file(file_writer: SceneFileWriter) -> None:
Expand Down