Add files via upload

Ready for flatpak
This commit is contained in:
Knud Schrøder
2025-11-24 18:44:07 +01:00
committed by GitHub
parent 2cf4d2bf68
commit d80d623dac
2 changed files with 33 additions and 10 deletions

Binary file not shown.

View File

@@ -46,17 +46,40 @@ ICON_PATH = PROJECT_PATH / "meshtastic.ico"
def _prefer_chrome(url: str):
# try Chrome first
chrome_paths = [
r"C:\Program Files\Google\Chrome\Application\chrome.exe",
r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
"""Open URL in a sensible browser on any OS.
On Flatpak/Linux we just use the default handler.
"""
# Try system default browser first (works well in Flatpak)
try:
webbrowser.open(url)
return
except Exception:
pass
# Fallbacks for some common desktop setups
candidate_browsers = [
# Linux / BSD
"xdg-open",
"gio open",
"sensible-browser",
"google-chrome-stable",
"chromium",
# Windows (if someone still runs it there)
r"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
r"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
]
for p in chrome_paths:
if os.path.exists(p):
subprocess.Popen([p, url])
return
# fallback
webbrowser.open(url)
for cmd in candidate_browsers:
try:
if os.path.isabs(cmd) and os.path.exists(cmd):
subprocess.Popen([cmd, url])
return
else:
# Let the shell resolve it from PATH
subprocess.Popen(cmd.split() + [url])
return
except Exception:
continue
def _fmt_ago(epoch_seconds: Optional[float]) -> str: