Skip to content


fix: replace with xdg-open with original LD_LIBRARY_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-bjareholt committed Jun 26, 2020
1 parent eadf39d commit bcd27a0
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions aw_qt/
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sys
import logging
import signal
import webbrowser
import os
import subprocess
import webbrowser

from PyQt5 import QtCore
from PyQt5.QtWidgets import QApplication, QSystemTrayIcon, QMessageBox, QMenu, QWidget, QPushButton
Expand All @@ -16,14 +16,40 @@
logger = logging.getLogger(__name__)

def get_env():
Necessary for xdg-open to work properly when PyInstaller overrides LD_LIBRARY_PATH
env = dict(os.environ) # make a copy of the environment
lp_key = 'LD_LIBRARY_PATH' # for GNU/Linux and *BSD.
lp_orig = env.get(lp_key + '_ORIG')
if lp_orig is not None:
env[lp_key] = lp_orig # restore the original, unmodified value
# This happens when LD_LIBRARY_PATH was not set.
# Remove the env var as a last resort:
env.pop(lp_key, None)
return env

def open_url(url):
if sys.platform == "linux":
env = get_env()
subprocess.Popen(["xdg-open", url], env=env)

def open_webui(root_url):
print("Opening dashboard")

def open_apibrowser(root_url):
print("Opening api browser") + "/api")
open_url(root_url + "/api")

def open_dir(d):
Expand Down

0 comments on commit bcd27a0

Please sign in to comment.