GNU bug report logs - #37847
[PATCH] Improve client/daemon xdg/systemd experience

Previous Next

Package: emacs;

Reported by: Carlos Pita <carlosjosepita <at> gmail.com>

Date: Mon, 21 Oct 2019 07:17:02 UTC

Severity: wishlist

Tags: fixed

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37847 in the body.
You can then email your comments to 37847 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Mon, 21 Oct 2019 07:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Carlos Pita <carlosjosepita <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 21 Oct 2019 07:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Improve client/daemon xdg/systemd experience
Date: Mon, 21 Oct 2019 04:15:50 -0300
[Message part 1 (text/plain, inline)]
The attached patch adds an emacsclient.desktop launcher with
StartWMClass=Emacsclient and also makes systemd start the daemon with
name emacsclient.

This is intended to fix a number of shortcomings in emacs xdg/systemd
integration:

1. There is no emacsclient desktop launcher.

2. emacsclient run with the same class/name hints than emacs, so:

2.1 It's not possible to add it to dock/dash/panel favorites since
desktops identify the launcher for a window using its hints. So you
always get an emacs launcher instead of the emacsclient one.

2.2 Even if manually added to dock/dash/panel, launched frames will
not group under this icon but under the one where standalone emacs
instances group.

The only drawback I can think of is that X resources not specified by
class (Emacs) but by name (emacs vs. emacsclient) will fail to apply.
But I don't think this is usual practice. Note that even if xprop
reports Emacsclient as the class hint, resource resolution always uses
Emacs, so we're ok with that.

Best regards
--
Carlos
[0001-Improve-client-daemon-xdg-systemd-experience.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Mon, 21 Oct 2019 07:28:02 GMT) Full text and rfc822 format available.

Message #8 received at 37847 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 37847 <at> debbugs.gnu.org
Subject: Re: [PATCH] Improve client/daemon xdg/systemd experience
Date: Mon, 21 Oct 2019 04:27:17 -0300
[Message part 1 (text/plain, inline)]
I've changed the name of the emacsclient launcher from "Emacs" to
"Emacs (Client)".

Also added the bug number to the commit message.

One last remark: the name emacsclient to run `emacs --daemon` is
admittedly confusing. OTOH, it is natural as the name of the frames
later launched by the daemon (in particular, it's natural as
StartWMClass). If you prefer I can change it, though.
[0001-Improve-client-daemon-xdg-systemd-experience-Bug-378.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Mon, 21 Oct 2019 15:38:01 GMT) Full text and rfc822 format available.

Message #11 received at 37847 <at> debbugs.gnu.org (full text, mbox):

From: Carlos Pita <carlosjosepita <at> gmail.com>
To: 37847 <at> debbugs.gnu.org
Subject: Re: [PATCH] Improve client/daemon xdg/systemd experience
Date: Mon, 21 Oct 2019 12:37:24 -0300
[Message part 1 (text/plain, inline)]
> One last remark: the name emacsclient to run `emacs --daemon` is admittedly confusing.

I've renamed it to emacsd since it's launched by systemd. Now it's a
bit confusing that StartupWMClass = Emacsd, but I think it's
preferable to the alternative.
[0001-Improve-client-daemon-xdg-systemd-experience-Bug-378.patch (text/x-patch, attachment)]

Severity set to 'wishlist' from 'normal' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 15 Apr 2020 01:26:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Sun, 09 Aug 2020 14:00:01 GMT) Full text and rfc822 format available.

Message #16 received at 37847 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Carlos Pita <carlosjosepita <at> gmail.com>
Cc: 37847 <at> debbugs.gnu.org
Subject: Re: bug#37847: [PATCH] Improve client/daemon xdg/systemd experience
Date: Sun, 09 Aug 2020 15:59:02 +0200
Carlos Pita <carlosjosepita <at> gmail.com> writes:

> Subject: [PATCH] Improve client/daemon xdg/systemd experience (Bug#37847)
>
> * Makefile.in: Add emacsclient.desktop generation.
> * etc/emacsclient.desktop: Add file, use emacsd as StartupWMClass.
> * etc/emacs.service: Run with name emacsd.

Thanks.

I'm not very familiar with how systemd works, but from my limited
knowledge of it, I think this makes sense?  So I've applied your patch
to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 09 Aug 2020 14:00:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 37847 <at> debbugs.gnu.org and Carlos Pita <carlosjosepita <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 09 Aug 2020 14:00:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 07 Sep 2020 11:24:06 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Vojtěch Štěpančík <vojtechstepancik <at> outlook.com> to control <at> debbugs.gnu.org. (Tue, 08 Sep 2020 15:55:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Tue, 08 Sep 2020 21:47:01 GMT) Full text and rfc822 format available.

Message #27 received at 37847 <at> debbugs.gnu.org (full text, mbox):

From: Vojtech Stepancik <vojtechstepancik <at> outlook.com>
To: 37847 <at> debbugs.gnu.org
Subject: Re: bug#37847: [PATCH] Improve client/daemon xdg/systemd experience
Date: Tue, 08 Sep 2020 23:46:01 +0200
This appears to break packages that rely on `invocation-name' to 
be
executable.

When started as a systemd service, the `invocation-name' of the 
server
process
is `emacsd', which is not indicative of the way the process was
launched.

For example Flycheck tries to use this variable to compile elisp 
code
with the same
version of Emacs as the one being used. I'm sure there are others.

Would it be possible to not alter the argv of the daemon under
systemd?

Thanks for consideration.

Vojtěch Štěpančík




bug No longer marked as fixed in versions 28.1 and reopened. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 08 Sep 2020 22:04:01 GMT) Full text and rfc822 format available.

Removed tag(s) patch and fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 08 Sep 2020 22:04:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Wed, 09 Sep 2020 09:36:01 GMT) Full text and rfc822 format available.

Message #34 received at 37847 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Vojtech Stepancik <vojtechstepancik <at> outlook.com>
Cc: 37847 <at> debbugs.gnu.org
Subject: Re: bug#37847: [PATCH] Improve client/daemon xdg/systemd experience
Date: Wed, 09 Sep 2020 11:35:37 +0200
Vojtech Stepancik <vojtechstepancik <at> outlook.com> writes:

> When started as a systemd service, the `invocation-name' of the server
> process is `emacsd', which is not indicative of the way the process
> was launched.
>
> For example Flycheck tries to use this variable to compile elisp code
> with the same version of Emacs as the one being used. I'm sure there
> are others.

Would reverting this bit of the patch fix the problem?

 [Service]
 Type=notify
-ExecStart=emacs --fg-daemon
+ExecStart=@emacs emacsd --fg-daemon
 ExecStop=emacsclient --eval "(kill-emacs)"


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Wed, 09 Sep 2020 09:48:02 GMT) Full text and rfc822 format available.

Message #37 received at 37847 <at> debbugs.gnu.org (full text, mbox):

From: Vojtech Stepancik <vojtechstepancik <at> outlook.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 37847 <at> debbugs.gnu.org
Subject: Re: bug#37847: [PATCH] Improve client/daemon xdg/systemd experience
Date: Wed, 09 Sep 2020 11:47:04 +0200
Yes, that fixes my issue, however as I'm not quite sure why it was 
introduced in the first place, I don't know how it interacts with 
the rest of the patch.

Lars Ingebrigtsen writes:

>
> Would reverting this bit of the patch fix the problem?
>
>  [Service]
>  Type=notify
> -ExecStart=emacs --fg-daemon
> +ExecStart=@emacs emacsd --fg-daemon
>  ExecStop=emacsclient --eval "(kill-emacs)"




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Wed, 09 Sep 2020 10:10:02 GMT) Full text and rfc822 format available.

Message #40 received at 37847 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Vojtech Stepancik <vojtechstepancik <at> outlook.com>
Cc: Carlos Pita <carlosjosepita <at> gmail.com>, 37847 <at> debbugs.gnu.org
Subject: Re: bug#37847: [PATCH] Improve client/daemon xdg/systemd experience
Date: Wed, 09 Sep 2020 12:09:24 +0200
Vojtech Stepancik <vojtechstepancik <at> outlook.com> writes:

> Yes, that fixes my issue, however as I'm not quite sure why it was
> introduced in the first place, I don't know how it interacts with the
> rest of the patch.
>
> Lars Ingebrigtsen writes:
>
>>
>> Would reverting this bit of the patch fix the problem?
>>
>>  [Service]
>>  Type=notify
>> -ExecStart=emacs --fg-daemon
>> +ExecStart=@emacs emacsd --fg-daemon
>>  ExecStop=emacsclient --eval "(kill-emacs)"

Yeah, me neither.  Perhaps Carlos has some insight here...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Tue, 13 Oct 2020 03:50:02 GMT) Full text and rfc822 format available.

Message #43 received at 37847 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Vojtech Stepancik <vojtechstepancik <at> outlook.com>
Cc: Carlos Pita <carlosjosepita <at> gmail.com>, 37847 <at> debbugs.gnu.org
Subject: Re: bug#37847: [PATCH] Improve client/daemon xdg/systemd experience
Date: Tue, 13 Oct 2020 05:48:47 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Vojtech Stepancik <vojtechstepancik <at> outlook.com> writes:
>
>> Yes, that fixes my issue, however as I'm not quite sure why it was
>> introduced in the first place, I don't know how it interacts with the
>> rest of the patch.
>>
>> Lars Ingebrigtsen writes:
>>
>>>
>>> Would reverting this bit of the patch fix the problem?
>>>
>>>  [Service]
>>>  Type=notify
>>> -ExecStart=emacs --fg-daemon
>>> +ExecStart=@emacs emacsd --fg-daemon
>>>  ExecStop=emacsclient --eval "(kill-emacs)"
>
> Yeah, me neither.  Perhaps Carlos has some insight here...

This was four weeks ago, so I've now pushed this partial reversion to
the trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 13 Oct 2020 03:50:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 37847 <at> debbugs.gnu.org and Carlos Pita <carlosjosepita <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 13 Oct 2020 03:50:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 10 Nov 2020 12:24:07 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Peter Oliver <p.d.oliver <at> mavit.org.uk> to control <at> debbugs.gnu.org. (Fri, 28 May 2021 17:20:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37847; Package emacs. (Fri, 28 May 2021 17:23:02 GMT) Full text and rfc822 format available.

Message #54 received at 37847 <at> debbugs.gnu.org (full text, mbox):

From: Peter Oliver <p.d.oliver <at> mavit.org.uk>
To: 37847 <at> debbugs.gnu.org
Subject: Re: [PATCH] Improve client/daemon xdg/systemd experience
Date: Fri, 28 May 2021 18:21:55 +0100 (BST)
[Message part 1 (text/plain, inline)]
In the systemd service, I believe that Carlos was setting $0 to emacsd for the following effect:

$ xprop -name emacsd@$HOST | grep WM_CLASS
WM_CLASS(STRING) = "emacsd", "Emacsd"

This is because desktops use the StartupWMClass in the .desktop file to match which windows are associated with which .desktop file, and we want a daemonised Emacs to be matched to emacsclient.desktop rather than emacs.desktop.

Consequently, now that this section of the patch has been reverted, the following line remaining in emacsclient.desktop makes no sense:

StartupWMClass=Emacsd


Perhaps we can find a different way of setting the WM_CLASS X11 property?

Alternatively, if we merge the two .desktop files, this issue goes away.  There is currently some discussion of doing this for other reasons on emacs-devel.


I’ve unarchived bug 37847 in order to add this comment, and hope that that isn’t a breach of etiquette.  I’ll happily raise a new bug if that’s preferred.

-- 
Peter Oliver

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 26 Jun 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 304 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.