Il 07/01/2024 06:44, Max Nikulin ha scritto:
It seems neither su nor sudo add process to the user context (proper
cgroup, XDG session), so attempts to talk to the systemd user session
through D-Bus fail.
setpriv --reuid 1000 --regid 1000 --init-groups --reset-env -- \
env XDG_RUNTIME_DIR="/run/user/1000" \
systemd-run --user --slice=app.slice -- \
xterm
I have realized that earlier I forgot to add --user to systemd-run. To
my surprise, it does not work if I set
BUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus" instead of
XDG_RUNTIME_DIR. I expected that the former is required for systemd-run.
This command works from a root shell prompt, I hope it should work
during resume as well.
It works :-)
setpriv --reuid="$kafuid" --regid="$kafgid" --init-groups --reset-env \
env XDG_RUNTIME_DIR=/run/user/"$kafuid" $kafdis
XDG_CURRENT_DESKTOP=KDE \
systemd-run --user --slice=app.slice /usr/bin/kaffeine
--lastchannel > /dev/null 2>&1
Even during resume it goes into right slice.