33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
#!/opt/hermes/.venv/bin/python
|
|
"""Open XFCE's preferred browser using Hermes' own per-Screen launch policy."""
|
|
import json
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def launch_args():
|
|
config = Path(os.environ.get("XDG_CONFIG_HOME", "")).resolve()
|
|
base = Path("/opt/data").resolve()
|
|
if config.name != "xdg" or config.parent.name != "bot-desktop":
|
|
raise RuntimeError("Run this launcher from a Hermes Bot Screen.")
|
|
home = config.parent.parent
|
|
if home != base and (home.parent != base / "profiles" or not home.is_dir()):
|
|
raise RuntimeError("Unexpected Hermes Screen profile directory.")
|
|
os.environ["HERMES_HOME"] = str(home)
|
|
sys.path.insert(0, "/opt/hermes")
|
|
from tools.bot_desktop import browser
|
|
|
|
selected = browser.dock_launch()
|
|
if selected is None:
|
|
raise RuntimeError("Hermes has no headed browser available.")
|
|
return browser.dock_argv(*selected)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
args = launch_args()
|
|
if sys.argv[1:] == ["--check"]:
|
|
print(json.dumps(args))
|
|
else:
|
|
os.execv(args[0], args + sys.argv[1:])
|