You are not logged in.
I use emacsclient and therefore have the (user-) systemd daemon enabled. But after system startup and logging into my desktop environment (GNOME, Wayland) I can't start emacs (client):
emacsclient.desktop[5312]: Waiting for Emacs...*ERROR*: Display :0 can’t be opened
systemd[1261]: app-gnome-emacsclient-5312.scope: Couldn't move process 5312 to requested cgroup '/user.slice/user-1000.slice/user@1000.service/app.slice/app-gnome-emacsclient-5312.scope': No such process
dleyna-renderer-service[5242]: dLeyna: Exit
systemd[1261]: app-gnome-emacsclient-5312.scope: Failed to add PIDs to scope's control group: No such process
systemd[1261]: app-gnome-emacsclient-5312.scope: Failed with result 'resources'.
systemd[1261]: Failed to start Application launched by gnome-shell.
But after restarting the daemon it works. What could be the reason, or how can I fix this?
Last edited by beedaddy (2022-12-05 07:15:49)
Offline
https://wiki.archlinux.org/title/System … XAUTHORITY
Because of "GNOME, Wayland" and "Display :0 can’t be opened" I'd check the actual "echo $DISPLAY" in your session (which is going to be an xwayland session)
In doubt inspect the environment of the re-launched emacs daemon.
Offline
I'm not sure I understand your hint. "echo $DISPLAY" shows me ":0".
(Since restarting the daemon helps, I suspect it started too early at boot time.)
Offline
The variable needs to be exported to the systemd user service. Do you?
Offline
Well, I only use the configuration file for the Emacs daemon provided by the Emacs package. I have not made any customizations. This is the (original) file:
[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
[Service]
Type=notify
ExecStart=/usr/bin/emacs --fg-daemon
# Emacs will exit with status 15 after having received SIGTERM, which
# is the default "KillSignal" value systemd uses to stop services.
SuccessExitStatus=15
# The location of the SSH auth socket varies by distribution, and some
# set it from PAM, so don't override by default.
# Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure
[Install]
WantedBy=default.target
Offline
Did you try explicitly exporting the DISPLAY for the service?
The "wayland" aspect will possibly result in a condition where the service is started, but no DISPLAY set.
Also inspect "systemctl --user status emacs.service"
Offline
Emacs will not run natively under wayland. You could also consider to build your own emacs using emacs-git from AUR, with PGTK="YES" set in the header of the PKGBUILD.
Offline
If i understand your post correctly, I had a similar issue starting a user session of tmux at startup.
What worked for me was to have Gnome desktop itself autostart the user service this way all the environment variables are set and passed properly. I think the way to do it is via a .desktop file. I just linked it to a simple script -- see below for details YMMV.
$ cat ~/.local/share/applications/import_env.desktop
[Desktop Entry]
Type=Application
Name=import-env
Comment=import graphical environment to systemd user session
Exec=/home/ghost/.local/bin/scripts/import_env.sh
Terminal=false
X-GNOME-Autostart-enabled=true
$ cat ~/.local/bin/scripts/import_env.sh
#!/usr/bin/env bash
systemctl --user start tmux.service
"the wind-blown way, wanna win? don't play"
Offline
Thanks for your comments. My workaround I came up with is to start the Emacs daemon via autostart, that is, putting a emacs.desktop file into $HOME/.config/autostart. It's certainly pretty ... pragmatic and rudimentary, but as far as I can see it does what it's supposed to. The file contains:
[Desktop Entry]
Name=Emacs
GenericName=Text Editor
Comment=Edit text
Exec="/usr/bin/emacs" --daemon
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupNotify=true
StartupWMClass=Emacs
Offline
It's certainly pretty ...
… much a straight forward way to do things.
If you still want to use a systemd user service (I'm certainly not telling you to do…), though:
Did you try explicitly exporting the DISPLAY for the service?
Offline
If you still want to use a systemd user service (I'm certainly not telling you to do…), though:
seth wrote:Did you try explicitly exporting the DISPLAY for the service?
No. How would I have to do that?
Offline
https://wiki.archlinux.org/title/System … ce_example
You can also edit the specific service (don't forget --user) unit and add the DISPLAY Environment
Offline