Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X lock files are created which prevents Xwayland from starting #178

Open
bbb651 opened this issue Jan 16, 2025 · 0 comments
Open

X lock files are created which prevents Xwayland from starting #178

bbb651 opened this issue Jan 16, 2025 · 0 comments

Comments

@bbb651
Copy link

bbb651 commented Jan 16, 2025

I'm using cosmic-greeter with greetd with a niri session, and xwayland-satellite for Xwayland support.
Since updating my (archlinux) system, specifically:

cosmic-greeter 1.0.0.alpha.5-1
cosmic-comp 1.0.0.alpha.5-1
niri 25.01-1
greetd 0.10.3-1
xwayland-satellite 0.5-2

The following files are created when logging in:

~$ ll -a /tmp | grep \\.X
-rw-r--r--  1 cosmic-greeter cosmic-greeter   11 Jan 16 19:15 .X0-lock
drwxrwxrwt  2 root           root             60 Jan 16 19:15 .X11-unix
drwxrwxrwt  2 root           root             40 Jan 16 19:15 .XIM-unix

Which prevent Xwayland (both rootful and rootless, including xwayland-satellite) from launching as display 0 (the default):

~$ Xwayland
(EE)
Fatal server error:
(EE) Could not create server lock file: /tmp/.X0-lock
(EE)

After removing /tmp/.X0-lock:

~$ Xwayland
_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)

After removing /tmp/.X0-unix it finally launches.

The lock files are created again when Xwayland starts but are owned by my user instead of cosmic-greeter (.XIM-unix isn't recreated if I remove it):

~$ ll -a /tmp | grep \\.X
-r--r--r--  1 bbb651 bbb651   11 Jan 16 22:04 .X0-lock
drwxrwxrwt  2 bbb651 bbb651   60 Jan 16 22:04 .X11-unix
drwxrwxrwt  2 root   root     40 Jan 16 19:15 .XIM-unix

Session files:

/usr/share/wayland-sessions/niri.desktop
[Desktop Entry]
Name=Niri
Comment=A scrollable-tiling Wayland compositor
Exec=niri-session
Type=Application
DesktopNames=niri
/usr/bin/niri-session
#!/bin/sh

if [ -n "$SHELL" ] &&
   grep -q "$SHELL" /etc/shells &&
   ! (echo "$SHELL" | grep -q "false") &&
   ! (echo "$SHELL" | grep -q "nologin"); then
  if [ "$1" != '-l' ]; then
    exec bash -c "exec -l '$SHELL' -c '$0 -l $*'"
  else
    shift
  fi
fi

# Try to detect the service manager that is being used
if hash systemctl &> /dev/null; then
    # Make sure there's no already running session.
    if systemctl --user -q is-active niri.service; then
      echo 'A niri session is already running.'
      exit 1
    fi

    # Reset failed state of all user units.
    systemctl --user reset-failed

    # Import the login manager environment.
    systemctl --user import-environment

    # DBus activation environment is independent from systemd. While most of
    # dbus-activated services are already using `SystemdService` directive, some
    # still don't and thus we should set the dbus environment with a separate
    # command.
    if hash dbus-update-activation-environment 2>/dev/null; then
        dbus-update-activation-environment --all
    fi

    # Start niri and wait for it to terminate.
    systemctl --user --wait start niri.service

    # Force stop of graphical-session.target.
    systemctl --user start --job-mode=replace-irreversibly niri-shutdown.target

    # Unset environment that we've set.
    systemctl --user unset-environment WAYLAND_DISPLAY XDG_SESSION_TYPE XDG_CURRENT_DESKTOP NIRI_SOCKET
elif hash dinitctl &> /dev/null; then
    # Check that the user dinit daemon is running
    if ! pgrep -u $(id -u) dinit &> /dev/null; then
      echo "dinit user daemon is not running."
      exit 1
    fi

    # Make sure there's no already running session.
    if dinitctl --user is-started niri &> /dev/null; then
      echo 'A niri session is already running.'
      exit 1
    fi

    # Start niri
    dinitctl --user start niri
else
    echo "No systemd or dinit detected, please use niri --session instead."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant