Skip to content

Commit 2d632d5

Browse files
committed
fix opening links
1 parent bbf4726 commit 2d632d5

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Thumbs.db
3535
*.rc
3636
/.qmake.cache
3737
/.qmake.stash
38-
.venv/
38+
.venv*/
3939
# ^ added by butterroach
4040
.pytest_cache/
4141
# ^ added by butterroach

app.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import platform
2222
import re
2323
import requests
24+
import subprocess
2425
import sys
2526
from packaging.version import Version
2627
from PySide6.QtWidgets import (
@@ -36,7 +37,7 @@
3637
from ui_form import Ui_App # generate ui_form.py: pyside6-uic form.ui -o ui_form.py
3738
from validateHosts import validateHostsFile
3839

39-
__version__ = "1.1.1"
40+
__version__ = "1.1.2"
4041

4142
TIMEOUT = 60
4243

@@ -50,11 +51,24 @@ def __init__(self, html_content, title, parent=None):
5051
label = QLabel(self)
5152
label.setTextFormat(Qt.RichText)
5253
label.setText(html_content)
53-
label.setOpenExternalLinks(True)
54+
label.linkActivated.connect(self.openLink)
5455

5556
layout.addWidget(label)
5657
self.setLayout(layout)
5758

59+
def openLink(self, link: str):
60+
# prevent any issues with opening browsers as root
61+
subprocess.Popen(
62+
[
63+
"sudo",
64+
"-u",
65+
os.getlogin(), # this will NOT return root, it will return the actual human user (source: believe me)
66+
"python3",
67+
"-c",
68+
f"__import__('webbrowser').open('{link}')",
69+
]
70+
) # very hacky lol but it works soooo
71+
5872

5973
class App(QMainWindow):
6074
def __init__(self, parent=None):

0 commit comments

Comments
 (0)