You are not logged in.

#1 2022-12-05 07:13:28

beedaddy
Member
From: Germany
Registered: 2015-02-26
Posts: 20

Problems starting emacsclient

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

#2 2022-12-05 09:01:27

seth
Member
Registered: 2012-09-03
Posts: 51,739

Re: Problems starting emacsclient

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

#3 2022-12-05 09:16:24

beedaddy
Member
From: Germany
Registered: 2015-02-26
Posts: 20

Re: Problems starting emacsclient

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

#4 2022-12-05 09:35:50

seth
Member
Registered: 2012-09-03
Posts: 51,739

Re: Problems starting emacsclient

The variable needs to be exported to the systemd user service. Do you?

Offline

#5 2022-12-05 09:41:35

beedaddy
Member
From: Germany
Registered: 2015-02-26
Posts: 20

Re: Problems starting emacsclient

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

#6 2022-12-05 14:18:07

seth
Member
Registered: 2012-09-03
Posts: 51,739

Re: Problems starting emacsclient

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

#7 2022-12-07 16:06:00

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 1,391

Re: Problems starting emacsclient

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

#8 2022-12-08 05:07:07

CarbonChauvinist
Member
Registered: 2012-06-16
Posts: 413
Website

Re: Problems starting emacsclient

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

#9 2022-12-08 06:56:48

beedaddy
Member
From: Germany
Registered: 2015-02-26
Posts: 20

Re: Problems starting emacsclient

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

#10 2022-12-08 07:16:18

seth
Member
Registered: 2012-09-03
Posts: 51,739

Re: Problems starting emacsclient

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:

seth wrote:

Did you try explicitly exporting the DISPLAY for the service?

Offline

#11 2022-12-08 14:33:28

beedaddy
Member
From: Germany
Registered: 2015-02-26
Posts: 20

Re: Problems starting emacsclient

seth wrote:

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

#12 2022-12-08 14:52:05

seth
Member
Registered: 2012-09-03
Posts: 51,739

Re: Problems starting emacsclient

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

Board footer

Powered by FluxBB