examples: windowed browser by default, so the session's desktop is visible
This commit is contained in:
1 parent
bfb333e9ff
commit
36541d22f4
1 file changed
+14
-5
@@ -122,7 +122,8 @@ def clear_screen(runtime_dir: str) -> None:
|
|||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
|
|
||||||
|
|
||||||
def start_browser(env: dict, *, url: str, port: int, home: pathlib.Path) -> subprocess.Popen:
|
def start_browser(env: dict, *, url: str, port: int, home: pathlib.Path,
|
||||||
|
fullscreen: bool = False) -> subprocess.Popen:
|
||||||
home.mkdir(parents=True, exist_ok=True)
|
home.mkdir(parents=True, exist_ok=True)
|
||||||
profile = home / "profile"
|
profile = home / "profile"
|
||||||
env = {**env, "HOME": str(home)}
|
env = {**env, "HOME": str(home)}
|
||||||
@@ -134,8 +135,11 @@ def start_browser(env: dict, *, url: str, port: int, home: pathlib.Path) -> subp
|
|||||||
# invocation the module's own manual testing used.
|
# invocation the module's own manual testing used.
|
||||||
"--no-sandbox",
|
"--no-sandbox",
|
||||||
"--disable-dev-shm-usage",
|
"--disable-dev-shm-usage",
|
||||||
"--kiosk",
|
# Windowed by default: the session's wallpaper, gaps and window borders
|
||||||
"--window-size=1280,720",
|
# are the point of filming a *desktop*, and a kiosk window hides all of
|
||||||
|
# them. `--fullscreen` brings back the full-bleed browser.
|
||||||
|
*(["--kiosk"] if fullscreen else []),
|
||||||
|
"--window-size=1040,560",
|
||||||
f"--user-data-dir={profile}",
|
f"--user-data-dir={profile}",
|
||||||
"--no-first-run",
|
"--no-first-run",
|
||||||
"--no-default-browser-check",
|
"--no-default-browser-check",
|
||||||
@@ -145,7 +149,8 @@ def start_browser(env: dict, *, url: str, port: int, home: pathlib.Path) -> subp
|
|||||||
"--remote-debugging-address=127.0.0.1",
|
"--remote-debugging-address=127.0.0.1",
|
||||||
url,
|
url,
|
||||||
]
|
]
|
||||||
log(f"browser: starting chromium (debug port {port}) at {url}")
|
log(f"browser: starting chromium (debug port {port}, "
|
||||||
|
f"{'kiosk' if fullscreen else 'windowed'}) at {url}")
|
||||||
return subprocess.Popen(argv, env=env, stdout=subprocess.DEVNULL,
|
return subprocess.Popen(argv, env=env, stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
@@ -353,6 +358,9 @@ def main() -> int:
|
|||||||
parser.add_argument("--capture-fps", type=float, default=15.0,
|
parser.add_argument("--capture-fps", type=float, default=15.0,
|
||||||
help="frames per second to keep (default: %(default)s)")
|
help="frames per second to keep (default: %(default)s)")
|
||||||
parser.add_argument("--debug-port", type=int, default=9222)
|
parser.add_argument("--debug-port", type=int, default=9222)
|
||||||
|
parser.add_argument("--fullscreen", action="store_true",
|
||||||
|
help="kiosk/full-bleed browser instead of a windowed one "
|
||||||
|
"(hides the session's wallpaper and window borders)")
|
||||||
parser.add_argument("--work-dir", type=pathlib.Path, default=None,
|
parser.add_argument("--work-dir", type=pathlib.Path, default=None,
|
||||||
help="where frames land (default: a temp dir)")
|
help="where frames land (default: a temp dir)")
|
||||||
parser.add_argument("--clear-screen", action="store_true",
|
parser.add_argument("--clear-screen", action="store_true",
|
||||||
@@ -381,7 +389,8 @@ def main() -> int:
|
|||||||
out.parent.mkdir(parents=True, exist_ok=True)
|
out.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
browser = start_browser(env, url="https://www.google.com",
|
browser = start_browser(env, url="https://www.google.com",
|
||||||
port=args.debug_port, home=work / "home")
|
port=args.debug_port, home=work / "home",
|
||||||
|
fullscreen=args.fullscreen)
|
||||||
devtools = None
|
devtools = None
|
||||||
recorder = None
|
recorder = None
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in new issue
Block a user