mirror of
https://github.com/duckyPad/duckyPad-Configurator.git
synced 2026-11-19 12:19:07 +01:00
better handling of opening url in sudo
This commit is contained in:
+8
-7
@@ -27,13 +27,14 @@ ext_lib_path = os.path.join(app_save_path, "dpds_libs")
|
||||
|
||||
def open_url_safe(url):
|
||||
if sys.platform.startswith('linux') and os.geteuid() == 0:
|
||||
sudo_user = os.environ.get('SUDO_USER')
|
||||
if sudo_user:
|
||||
try:
|
||||
subprocess.Popen(['sudo', '-u', sudo_user, 'xdg-open', url])
|
||||
return
|
||||
except OSError:
|
||||
pass
|
||||
print(f"\nPlease open this URL manually ------> {url}\n")
|
||||
try:
|
||||
from tkinter import messagebox
|
||||
messagebox.showinfo(title="Info",message="Cannot open webbrowser as root.\n\nPlease click the link printed in your terminal manually.")
|
||||
return
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return
|
||||
webbrowser.open(url)
|
||||
|
||||
def open_discord_link():
|
||||
|
||||
Reference in New Issue
Block a user