We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
-fp does not work on Ubuntu 
On Ubuntu, when passing -f flag (open the file in file browser) and -p (preview) no preview is shown, only the file browser is open, instead of both. 

IIRC it is working on windows, as I remember having worked on this flag to make it work on Windows. 

Seems like an easy PR 
-fp does not work on Ubuntu 
On Ubuntu, when passing -f flag (open the file in file browser) and -p (preview) no preview is shown, only the file browser is open, instead of both. 

IIRC it is working on windows, as I remember having worked on this flag to make it work on Windows. 

Seems like an easy PR 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `manim/__main__.py`
Content:
```
1 import inspect
2 import os
3 import platform
4 import subprocess as sp
5 import sys
6 import re
7 import traceback
8 import importlib.util
9 import types
10 
11 from . import constants, logger, console, file_writer_config
12 from .config.config import args
13 from .config import cfg_subcmds
14 from .scene.scene import Scene
15 from .utils.sounds import play_error_sound, play_finish_sound
16 from .utils.file_ops import open_file as open_media_file
17 from . import constants
18 
19 
20 def open_file_if_needed(file_writer):
21     if file_writer_config["verbosity"] != "DEBUG":
22         curr_stdout = sys.stdout
23         sys.stdout = open(os.devnull, "w")
24 
25     open_file = any(
26         [file_writer_config["preview"], file_writer_config["show_in_file_browser"]]
27     )
28     if open_file:
29         current_os = platform.system()
30         file_paths = []
31 
32         if file_writer_config["save_last_frame"]:
33             file_paths.append(file_writer.get_image_file_path())
34         if (
35             file_writer_config["write_to_movie"]
36             and not file_writer_config["save_as_gif"]
37         ):
38             file_paths.append(file_writer.get_movie_file_path())
39         if file_writer_config["save_as_gif"]:
40             file_paths.append(file_writer.gif_file_path)
41 
42         for file_path in file_paths:
43             open_media_file(file_path, file_writer_config["show_in_file_browser"])
44 
45     if file_writer_config["verbosity"] != "DEBUG":
46         sys.stdout.close()
47         sys.stdout = curr_stdout
48 
49 
50 def is_child_scene(obj, module):
51     return (
52         inspect.isclass(obj)
53         and issubclass(obj, Scene)
54         and obj != Scene
55         and obj.__module__.startswith(module.__name__)
56     )
57 
58 
59 def prompt_user_for_choice(scene_classes):
60     num_to_class = {}
61     for count, scene_class in enumerate(scene_classes):
62         count += 1  # start with 1 instead of 0
63         name = scene_class.__name__
64         console.print(f"{count}: {name}", style="logging.level.info")
65         num_to_class[count] = scene_class
66     try:
67         user_input = console.input(
68             f"[log.message] {constants.CHOOSE_NUMBER_MESSAGE} [/log.message]"
69         )
70         return [
71             num_to_class[int(num_str)]
72             for num_str in re.split(r"\s*,\s*", user_input.strip())
73         ]
74     except KeyError:
75         logger.error(constants.INVALID_NUMBER_MESSAGE)
76         sys.exit(2)
77     except EOFError:
78         sys.exit(1)
79 
80 
81 def get_scenes_to_render(scene_classes):
82     if not scene_classes:
83         logger.error(constants.NO_SCENE_MESSAGE)
84         return []
85     if file_writer_config["write_all"]:
86         return scene_classes
87     result = []
88     for scene_name in file_writer_config["scene_names"]:
89         found = False
90         for scene_class in scene_classes:
91             if scene_class.__name__ == scene_name:
92                 result.append(scene_class)
93                 found = True
94                 break
95         if not found and (scene_name != ""):
96             logger.error(constants.SCENE_NOT_FOUND_MESSAGE.format(scene_name))
97     if result:
98         return result
99     return (
100         [scene_classes[0]]
101         if len(scene_classes) == 1
102         else prompt_user_for_choice(scene_classes)
103     )
104 
105 
106 def get_scene_classes_from_module(module):
107     return [
108         member[1]
109         for member in inspect.getmembers(module, lambda x: is_child_scene(x, module))
110     ]
111 
112 
113 def get_module(file_name):
114     if file_name == "-":
115         # Since this feature is used for rapid testing, using Scene Caching would be a
116         # hindrance in this case.
117         file_writer_config["disable_caching"] = True
118         module = types.ModuleType("input_scenes")
119         logger.info(
120             "Enter the animation's code & end with an EOF (CTRL+D on Linux/Unix, CTRL+Z on Windows):"
121         )
122         code = sys.stdin.read()
123         if not code.startswith("from manim import"):
124             logger.warning(
125                 "Didn't find an import statement for Manim. Importing automatically..."
126             )
127             code = "from manim import *\n" + code
128         logger.info("Rendering animation from typed code...")
129         try:
130             exec(code, module.__dict__)
131             return module
132         except Exception as e:
133             logger.error(f"Failed to render scene: {str(e)}")
134             sys.exit(2)
135     else:
136         if os.path.exists(file_name):
137             if file_name[-3:] != ".py":
138                 raise Exception(f"{file_name} is not a valid Manim python script.")
139             module_name = file_name[:-3].replace(os.sep, ".").split(".")[-1]
140             spec = importlib.util.spec_from_file_location(module_name, file_name)
141             module = importlib.util.module_from_spec(spec)
142             spec.loader.exec_module(module)
143             return module
144         else:
145             raise FileNotFoundError(f"{file_name} not found")
146 
147 
148 def main():
149     if hasattr(args, "subcommands"):
150         if "cfg" in args.subcommands:
151             if args.cfg_subcommand is not None:
152                 subcommand = args.cfg_subcommand
153                 if subcommand == "write":
154                     cfg_subcmds.write(args.level, args.open)
155                 elif subcommand == "show":
156                     cfg_subcmds.show()
157                 elif subcommand == "export":
158                     cfg_subcmds.export(args.dir)
159             else:
160                 logger.error("No argument provided; Exiting...")
161 
162     else:
163         module = get_module(file_writer_config["input_file"])
164         all_scene_classes = get_scene_classes_from_module(module)
165         scene_classes_to_render = get_scenes_to_render(all_scene_classes)
166         sound_on = file_writer_config["sound"]
167         for SceneClass in scene_classes_to_render:
168             try:
169                 # By invoking, this renders the full scene
170                 scene = SceneClass()
171                 open_file_if_needed(scene.file_writer)
172                 if sound_on:
173                     play_finish_sound()
174             except Exception:
175                 print("\n\n")
176                 traceback.print_exc()
177                 print("\n\n")
178                 if sound_on:
179                     play_error_sound()
180 
181 
182 if __name__ == "__main__":
183     main()
184
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/manim/__main__.py b/manim/__main__.py
--- a/manim/__main__.py
+++ b/manim/__main__.py
@@ -40,7 +40,10 @@
             file_paths.append(file_writer.gif_file_path)
 
         for file_path in file_paths:
-            open_media_file(file_path, file_writer_config["show_in_file_browser"])
+            if file_writer_config["show_in_file_browser"]:
+                open_media_file(file_path, True)
+            if file_writer_config["preview"]:
+                open_media_file(file_path, False)
 
     if file_writer_config["verbosity"] != "DEBUG":
         sys.stdout.close()

{"golden_diff": "diff --git a/manim/__main__.py b/manim/__main__.py\n--- a/manim/__main__.py\n+++ b/manim/__main__.py\n@@ -40,7 +40,10 @@\n             file_paths.append(file_writer.gif_file_path)\n \n         for file_path in file_paths:\n-            open_media_file(file_path, file_writer_config[\"show_in_file_browser\"])\n+            if file_writer_config[\"show_in_file_browser\"]:\n+                open_media_file(file_path, True)\n+            if file_writer_config[\"preview\"]:\n+                open_media_file(file_path, False)\n \n     if file_writer_config[\"verbosity\"] != \"DEBUG\":\n         sys.stdout.close()\n", "issue": "-fp does not work on Ubuntu \nOn Ubuntu, when passing -f flag (open the file in file browser) and -p (preview) no preview is shown, only the file browser is open, instead of both. \r\n\r\nIIRC it is working on windows, as I remember having worked on this flag to make it work on Windows. \r\n\r\nSeems like an easy PR \n-fp does not work on Ubuntu \nOn Ubuntu, when passing -f flag (open the file in file browser) and -p (preview) no preview is shown, only the file browser is open, instead of both. \r\n\r\nIIRC it is working on windows, as I remember having worked on this flag to make it work on Windows. \r\n\r\nSeems like an easy PR \n", "before_files": [{"content": "import inspect\nimport os\nimport platform\nimport subprocess as sp\nimport sys\nimport re\nimport traceback\nimport importlib.util\nimport types\n\nfrom . import constants, logger, console, file_writer_config\nfrom .config.config import args\nfrom .config import cfg_subcmds\nfrom .scene.scene import Scene\nfrom .utils.sounds import play_error_sound, play_finish_sound\nfrom .utils.file_ops import open_file as open_media_file\nfrom . import constants\n\n\ndef open_file_if_needed(file_writer):\n    if file_writer_config[\"verbosity\"] != \"DEBUG\":\n        curr_stdout = sys.stdout\n        sys.stdout = open(os.devnull, \"w\")\n\n    open_file = any(\n        [file_writer_config[\"preview\"], file_writer_config[\"show_in_file_browser\"]]\n    )\n    if open_file:\n        current_os = platform.system()\n        file_paths = []\n\n        if file_writer_config[\"save_last_frame\"]:\n            file_paths.append(file_writer.get_image_file_path())\n        if (\n            file_writer_config[\"write_to_movie\"]\n            and not file_writer_config[\"save_as_gif\"]\n        ):\n            file_paths.append(file_writer.get_movie_file_path())\n        if file_writer_config[\"save_as_gif\"]:\n            file_paths.append(file_writer.gif_file_path)\n\n        for file_path in file_paths:\n            open_media_file(file_path, file_writer_config[\"show_in_file_browser\"])\n\n    if file_writer_config[\"verbosity\"] != \"DEBUG\":\n        sys.stdout.close()\n        sys.stdout = curr_stdout\n\n\ndef is_child_scene(obj, module):\n    return (\n        inspect.isclass(obj)\n        and issubclass(obj, Scene)\n        and obj != Scene\n        and obj.__module__.startswith(module.__name__)\n    )\n\n\ndef prompt_user_for_choice(scene_classes):\n    num_to_class = {}\n    for count, scene_class in enumerate(scene_classes):\n        count += 1  # start with 1 instead of 0\n        name = scene_class.__name__\n        console.print(f\"{count}: {name}\", style=\"logging.level.info\")\n        num_to_class[count] = scene_class\n    try:\n        user_input = console.input(\n            f\"[log.message] {constants.CHOOSE_NUMBER_MESSAGE} [/log.message]\"\n        )\n        return [\n            num_to_class[int(num_str)]\n            for num_str in re.split(r\"\\s*,\\s*\", user_input.strip())\n        ]\n    except KeyError:\n        logger.error(constants.INVALID_NUMBER_MESSAGE)\n        sys.exit(2)\n    except EOFError:\n        sys.exit(1)\n\n\ndef get_scenes_to_render(scene_classes):\n    if not scene_classes:\n        logger.error(constants.NO_SCENE_MESSAGE)\n        return []\n    if file_writer_config[\"write_all\"]:\n        return scene_classes\n    result = []\n    for scene_name in file_writer_config[\"scene_names\"]:\n        found = False\n        for scene_class in scene_classes:\n            if scene_class.__name__ == scene_name:\n                result.append(scene_class)\n                found = True\n                break\n        if not found and (scene_name != \"\"):\n            logger.error(constants.SCENE_NOT_FOUND_MESSAGE.format(scene_name))\n    if result:\n        return result\n    return (\n        [scene_classes[0]]\n        if len(scene_classes) == 1\n        else prompt_user_for_choice(scene_classes)\n    )\n\n\ndef get_scene_classes_from_module(module):\n    return [\n        member[1]\n        for member in inspect.getmembers(module, lambda x: is_child_scene(x, module))\n    ]\n\n\ndef get_module(file_name):\n    if file_name == \"-\":\n        # Since this feature is used for rapid testing, using Scene Caching would be a\n        # hindrance in this case.\n        file_writer_config[\"disable_caching\"] = True\n        module = types.ModuleType(\"input_scenes\")\n        logger.info(\n            \"Enter the animation's code & end with an EOF (CTRL+D on Linux/Unix, CTRL+Z on Windows):\"\n        )\n        code = sys.stdin.read()\n        if not code.startswith(\"from manim import\"):\n            logger.warning(\n                \"Didn't find an import statement for Manim. Importing automatically...\"\n            )\n            code = \"from manim import *\\n\" + code\n        logger.info(\"Rendering animation from typed code...\")\n        try:\n            exec(code, module.__dict__)\n            return module\n        except Exception as e:\n            logger.error(f\"Failed to render scene: {str(e)}\")\n            sys.exit(2)\n    else:\n        if os.path.exists(file_name):\n            if file_name[-3:] != \".py\":\n                raise Exception(f\"{file_name} is not a valid Manim python script.\")\n            module_name = file_name[:-3].replace(os.sep, \".\").split(\".\")[-1]\n            spec = importlib.util.spec_from_file_location(module_name, file_name)\n            module = importlib.util.module_from_spec(spec)\n            spec.loader.exec_module(module)\n            return module\n        else:\n            raise FileNotFoundError(f\"{file_name} not found\")\n\n\ndef main():\n    if hasattr(args, \"subcommands\"):\n        if \"cfg\" in args.subcommands:\n            if args.cfg_subcommand is not None:\n                subcommand = args.cfg_subcommand\n                if subcommand == \"write\":\n                    cfg_subcmds.write(args.level, args.open)\n                elif subcommand == \"show\":\n                    cfg_subcmds.show()\n                elif subcommand == \"export\":\n                    cfg_subcmds.export(args.dir)\n            else:\n                logger.error(\"No argument provided; Exiting...\")\n\n    else:\n        module = get_module(file_writer_config[\"input_file\"])\n        all_scene_classes = get_scene_classes_from_module(module)\n        scene_classes_to_render = get_scenes_to_render(all_scene_classes)\n        sound_on = file_writer_config[\"sound\"]\n        for SceneClass in scene_classes_to_render:\n            try:\n                # By invoking, this renders the full scene\n                scene = SceneClass()\n                open_file_if_needed(scene.file_writer)\n                if sound_on:\n                    play_finish_sound()\n            except Exception:\n                print(\"\\n\\n\")\n                traceback.print_exc()\n                print(\"\\n\\n\")\n                if sound_on:\n                    play_error_sound()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "manim/__main__.py"}], "after_files": [{"content": "import inspect\nimport os\nimport platform\nimport subprocess as sp\nimport sys\nimport re\nimport traceback\nimport importlib.util\nimport types\n\nfrom . import constants, logger, console, file_writer_config\nfrom .config.config import args\nfrom .config import cfg_subcmds\nfrom .scene.scene import Scene\nfrom .utils.sounds import play_error_sound, play_finish_sound\nfrom .utils.file_ops import open_file as open_media_file\nfrom . import constants\n\n\ndef open_file_if_needed(file_writer):\n    if file_writer_config[\"verbosity\"] != \"DEBUG\":\n        curr_stdout = sys.stdout\n        sys.stdout = open(os.devnull, \"w\")\n\n    open_file = any(\n        [file_writer_config[\"preview\"], file_writer_config[\"show_in_file_browser\"]]\n    )\n    if open_file:\n        current_os = platform.system()\n        file_paths = []\n\n        if file_writer_config[\"save_last_frame\"]:\n            file_paths.append(file_writer.get_image_file_path())\n        if (\n            file_writer_config[\"write_to_movie\"]\n            and not file_writer_config[\"save_as_gif\"]\n        ):\n            file_paths.append(file_writer.get_movie_file_path())\n        if file_writer_config[\"save_as_gif\"]:\n            file_paths.append(file_writer.gif_file_path)\n\n        for file_path in file_paths:\n            if file_writer_config[\"show_in_file_browser\"]:\n                open_media_file(file_path, True)\n            if file_writer_config[\"preview\"]:\n                open_media_file(file_path, False)\n\n    if file_writer_config[\"verbosity\"] != \"DEBUG\":\n        sys.stdout.close()\n        sys.stdout = curr_stdout\n\n\ndef is_child_scene(obj, module):\n    return (\n        inspect.isclass(obj)\n        and issubclass(obj, Scene)\n        and obj != Scene\n        and obj.__module__.startswith(module.__name__)\n    )\n\n\ndef prompt_user_for_choice(scene_classes):\n    num_to_class = {}\n    for count, scene_class in enumerate(scene_classes):\n        count += 1  # start with 1 instead of 0\n        name = scene_class.__name__\n        console.print(f\"{count}: {name}\", style=\"logging.level.info\")\n        num_to_class[count] = scene_class\n    try:\n        user_input = console.input(\n            f\"[log.message] {constants.CHOOSE_NUMBER_MESSAGE} [/log.message]\"\n        )\n        return [\n            num_to_class[int(num_str)]\n            for num_str in re.split(r\"\\s*,\\s*\", user_input.strip())\n        ]\n    except KeyError:\n        logger.error(constants.INVALID_NUMBER_MESSAGE)\n        sys.exit(2)\n    except EOFError:\n        sys.exit(1)\n\n\ndef get_scenes_to_render(scene_classes):\n    if not scene_classes:\n        logger.error(constants.NO_SCENE_MESSAGE)\n        return []\n    if file_writer_config[\"write_all\"]:\n        return scene_classes\n    result = []\n    for scene_name in file_writer_config[\"scene_names\"]:\n        found = False\n        for scene_class in scene_classes:\n            if scene_class.__name__ == scene_name:\n                result.append(scene_class)\n                found = True\n                break\n        if not found and (scene_name != \"\"):\n            logger.error(constants.SCENE_NOT_FOUND_MESSAGE.format(scene_name))\n    if result:\n        return result\n    return (\n        [scene_classes[0]]\n        if len(scene_classes) == 1\n        else prompt_user_for_choice(scene_classes)\n    )\n\n\ndef get_scene_classes_from_module(module):\n    return [\n        member[1]\n        for member in inspect.getmembers(module, lambda x: is_child_scene(x, module))\n    ]\n\n\ndef get_module(file_name):\n    if file_name == \"-\":\n        # Since this feature is used for rapid testing, using Scene Caching would be a\n        # hindrance in this case.\n        file_writer_config[\"disable_caching\"] = True\n        module = types.ModuleType(\"input_scenes\")\n        logger.info(\n            \"Enter the animation's code & end with an EOF (CTRL+D on Linux/Unix, CTRL+Z on Windows):\"\n        )\n        code = sys.stdin.read()\n        if not code.startswith(\"from manim import\"):\n            logger.warning(\n                \"Didn't find an import statement for Manim. Importing automatically...\"\n            )\n            code = \"from manim import *\\n\" + code\n        logger.info(\"Rendering animation from typed code...\")\n        try:\n            exec(code, module.__dict__)\n            return module\n        except Exception as e:\n            logger.error(f\"Failed to render scene: {str(e)}\")\n            sys.exit(2)\n    else:\n        if os.path.exists(file_name):\n            if file_name[-3:] != \".py\":\n                raise Exception(f\"{file_name} is not a valid Manim python script.\")\n            module_name = file_name[:-3].replace(os.sep, \".\").split(\".\")[-1]\n            spec = importlib.util.spec_from_file_location(module_name, file_name)\n            module = importlib.util.module_from_spec(spec)\n            spec.loader.exec_module(module)\n            return module\n        else:\n            raise FileNotFoundError(f\"{file_name} not found\")\n\n\ndef main():\n    if hasattr(args, \"subcommands\"):\n        if \"cfg\" in args.subcommands:\n            if args.cfg_subcommand is not None:\n                subcommand = args.cfg_subcommand\n                if subcommand == \"write\":\n                    cfg_subcmds.write(args.level, args.open)\n                elif subcommand == \"show\":\n                    cfg_subcmds.show()\n                elif subcommand == \"export\":\n                    cfg_subcmds.export(args.dir)\n            else:\n                logger.error(\"No argument provided; Exiting...\")\n\n    else:\n        module = get_module(file_writer_config[\"input_file\"])\n        all_scene_classes = get_scene_classes_from_module(module)\n        scene_classes_to_render = get_scenes_to_render(all_scene_classes)\n        sound_on = file_writer_config[\"sound\"]\n        for SceneClass in scene_classes_to_render:\n            try:\n                # By invoking, this renders the full scene\n                scene = SceneClass()\n                open_file_if_needed(scene.file_writer)\n                if sound_on:\n                    play_finish_sound()\n            except Exception:\n                print(\"\\n\\n\")\n                traceback.print_exc()\n                print(\"\\n\\n\")\n                if sound_on:\n                    play_error_sound()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "manim/__main__.py"}]}