Sample Header Ad - 728x90

Xorg not starting when invoked from Python

1 vote
0 answers
35 views
I'm creating a display manager (dm) in python, which waits to Xorg to start in order to run the GUI. ### Python (omitted unnecessary code like widgets and classes and functions)
import os

(more imports of PyQt6 etc ...)
.......

class LoginWindow( QMainWindow ):
    def __init__(self):
        super().__init__()
                
        # Make window full screen
        self.setWindowFlags(Qt.WindowType.FramelessWindowHint  | 
                            Qt.WindowType.WindowStaysOnTopHint
                            )

   ..........
   .......... (unnecessary code to the problem)
        
    def cancel(self, window):
        if not window :
             ...

def start_x11():
    xorg =subprocess.run("Xorg :0 -nolisten tcp -background none -logfile /var/log/mydm/xorg.log vt1",shell=True)
    return xorg

def start_user_session(username) :
    loginctl = subprocess.run(f"loginctl enable-linger {username}",shell=True)# ,capture_output=True)
    #print(loginctl)
    if loginctl.returncode == 0 :
        subprocess.run(f"sudo -u {username} dbus-launch startxfce4",shell=True)

if __name__ == "__main__" :
    
    if start_x11().returncode == 0 : 
        app = QApplication(sys.argv)
        app.setStyleSheet('''
            QPushButton#loginDockButton { 
                border: none;    
                padding: 0px;
                margin: 0px;
            }
        ''')


        window = LoginWindow()
        window.show()

        sys.exit(app.exec())
As you can see, i'm using **subprocess.run()** in order to run **Xorg**. And when asked to an **AI** to resolve the problem,i was recommended to run : subprocess.run("loginctl enable-linger {username}",shell=True) According to that **AI**, it let the users child processes to run even if logged out, this in order to prevent closing **dbus** process. **(though still wonder how this can help 🤔)** ### Unit Service
[Unit]
Description=mydm
Conflicts=getty@tty1.service
After=systemd-user-sessions.service plymouth-quit.service
Requires=systemd-logind.service

[Service]
ExecStart=/usr/bin/python3 /etc/mydm/src/mydm_login.py
Restart=always
RestartSec=3
StandardOutput=syslog
StandardError=syslog
TTYPath=/dev/tty1
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes

[Install]
WantedBy=graphical.target
I have to admit that the unit service code, was all generated by an **AI** because i didn't have any idea how unit files work and neither **systemd** or **systemctl** ### Logfile After some minutes of sadness and grief from not seeing my GUI, i decided to look at into the **logfile** from **Xorg** and got the next :
[  3671.154] Current Operating System: Linux MrDikxon 6.13.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 08 Feb 2025 18:54:55 +0000 x86_64
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.

grep EE /var/log/mydm/xorg.log
[  3671.154] (EE) systemd-logind: failed to get session: PID 4060 does not belong to any known session
[  3671.171] (EE) Failed to load module "fbdev" (module does not exist, 0)
[  3671.172] (EE) Failed to load module "vesa" (module does not exist, 0)
[  3671.186] (EE) open /dev/dri/card0: No such file or directory
[  3671.191] (II) Initializing extension MIT-SCREEN-SAVER
[  3671.193] (EE) AIGLX error: dlopen of /usr/lib/dri/i965_dri.so failed (/usr/lib/dri/i965_dri.so: cannot open shared object file: No such file or directory)
[  3671.193] (EE) AIGLX error: unable to load driver i965

grep WW /var/log/mydm/xorg.log 

[  3671.154] (WW) The directory "/usr/share/fonts/misc" does not exist.
[  3671.154] (WW) The directory "/usr/share/fonts/TTF" does not exist.
[  3671.154] (WW) The directory "/usr/share/fonts/OTF" does not exist.
[  3671.154] (WW) The directory "/usr/share/fonts/Type1" does not exist.
[  3671.154] (WW) The directory "/usr/share/fonts/100dpi" does not exist.
[  3671.154] (WW) The directory "/usr/share/fonts/75dpi" does not exist.
[  3671.169] (WW) Open ACPI failed (/var/run/acpid.socket) (No such file or directory)
[  3671.171] (WW) Warning, couldn't open module fbdev
[  3671.172] (WW) Warning, couldn't open module vesa
[  3671.186] (WW) Falling back to old probe method for modesetting
When doing it when (NI,??) didn't get any output. this is my first time working with Xorg or sysmted, so i dont know really what can i do. So i havent tried anything yet, and unix & linux stackexchange threads doesn't seem to relate much to what i need
Asked by rustymanito (35 rep)
Mar 14, 2025, 03:32 AM
Last activity: Mar 15, 2025, 04:42 AM