I am trying to run a Plasma session as a different user from bash by running sudo -u $TARGET_USER dbus-launch --exit-with-session startplasma-wayland
.
However, when trying to do so, I get an error “Could not create wayland socket”.
My goal is to start a Plasma session as a specified user, wait for the user to log out and continue running the script.
- Does anyone know how I might be able to fix this error?
- Do you know of another way to start a Plasma session as a different user and wait for the session to exit?
I also tried to do the same using the sudo --preserve-env --set-home XDG_RUNTIME_DIR=/run/users/$(id -u $TARGET_USER)
switches.
When doing so, I get the following messages repeatedly:
No backend specified, automatically choosing drm
kwin_core: Failed to take control of /org/freedesktop/login1/session/_311 session. Maybe another compositor is running?
kwin_wayland_drm: Failed to open drm device at "/dev/dri/card1"
kwin_wayland_drm: No suitable DRM devices have been found
However, logging in to the tty with the $TARGET_USER
directly and running dbus-launch --exit-with-session startplasma-wayland
works properly as expected.
Why not just log in as the user in TTY and then start it?
I’n not sure I understand the use-case of why it needs a Plasma session to start a script that needs to keep running afterwards. If the script itself does not need a plasma session, then you can just start it as a user service with systemd.
Thanks for your answer! I am writing a setup script which installs and configures my system automatically. As the creation of
rclone
configurations requires passwords, I wanted to boot up a Plasma Wayland session (for each user which needs to be created) and prompt them to create the necessaryrclone
configurations and sign out afterwards.My current (non functioning) draft of the script looks like this: https://git.nuth.ch/manuth/PortValhalla/src/commit/c88be78a7bce6b5d4d3bb64456b58366d1a1305d/scripts/Common/Software/rclone/main.fish#L10-L60