v1.8.68: auto-fix X display authorization on startup
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
34
main.py
34
main.py
@@ -5,14 +5,48 @@ ServerManager — GUI application for managing remote servers.
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
# Add project root to path
|
# Add project root to path
|
||||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
|
||||||
|
def _ensure_display_access():
|
||||||
|
"""Auto-fix X display authorization for root and non-owner users."""
|
||||||
|
display = os.environ.get("DISPLAY")
|
||||||
|
if not display:
|
||||||
|
# Try common displays
|
||||||
|
for d in (":0", ":1", ":0.0"):
|
||||||
|
os.environ["DISPLAY"] = d
|
||||||
|
display = d
|
||||||
|
break
|
||||||
|
try:
|
||||||
|
subprocess.run(["xhost", "+local:"], stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL, timeout=3)
|
||||||
|
except (FileNotFoundError, subprocess.TimeoutExpired):
|
||||||
|
pass
|
||||||
|
# Fallback: generate xauth cookie if xhost not available
|
||||||
|
if display:
|
||||||
|
try:
|
||||||
|
subprocess.run(["xdpyinfo"], stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL, timeout=3, check=True)
|
||||||
|
except (FileNotFoundError, subprocess.TimeoutExpired, subprocess.CalledProcessError):
|
||||||
|
try:
|
||||||
|
xauth_file = os.path.expanduser("~/.Xauthority")
|
||||||
|
os.environ.setdefault("XAUTHORITY", xauth_file)
|
||||||
|
subprocess.run(
|
||||||
|
["xauth", "generate", display, ".", "trusted"],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=5
|
||||||
|
)
|
||||||
|
except (FileNotFoundError, subprocess.TimeoutExpired):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
from gui.app import App
|
from gui.app import App
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
_ensure_display_access()
|
||||||
app = App()
|
app = App()
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
|
||||||
|
|||||||
BIN
releases/ServerManager-v1.8.68-linux-x64
Normal file
BIN
releases/ServerManager-v1.8.68-linux-x64
Normal file
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
"""Version info for ServerManager."""
|
"""Version info for ServerManager."""
|
||||||
|
|
||||||
__version__ = "1.8.67"
|
__version__ = "1.8.68"
|
||||||
__app_name__ = "ServerManager"
|
__app_name__ = "ServerManager"
|
||||||
__author__ = "aibot777"
|
__author__ = "aibot777"
|
||||||
__description__ = "Desktop GUI for managing remote servers"
|
__description__ = "Desktop GUI for managing remote servers"
|
||||||
|
|||||||
Reference in New Issue
Block a user