unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Some environment variables disappeared for getenv
@ 2022-09-15 11:12 Julien Cubizolles
  2022-09-15 12:53 ` tomas
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Cubizolles @ 2022-09-15 11:12 UTC (permalink / raw)
  To: emacs-devel

I used to rely on getenv to get the value of $XDG_SESSION_TYPE. I
noticed that recently:
--8<---------------cut here---------------start------------->8---
(getenv "XDG_SESSION_TYPE")
--8<---------------cut here---------------end--------------->8---
returns nil, because this variable isn't in process-environment

What is the reason for dropping this particular variable ? How can I get
the value of this variable from within Emacs ?

-- 
Julien Cubizolles




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Some environment variables disappeared for getenv
  2022-09-15 11:12 Some environment variables disappeared for getenv Julien Cubizolles
@ 2022-09-15 12:53 ` tomas
  2022-09-15 13:28   ` Julien Cubizolles
  0 siblings, 1 reply; 4+ messages in thread
From: tomas @ 2022-09-15 12:53 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 732 bytes --]

On Thu, Sep 15, 2022 at 01:12:02PM +0200, Julien Cubizolles wrote:
> I used to rely on getenv to get the value of $XDG_SESSION_TYPE. I
> noticed that recently:
> --8<---------------cut here---------------start------------->8---
> (getenv "XDG_SESSION_TYPE")
> --8<---------------cut here---------------end--------------->8---
> returns nil, because this variable isn't in process-environment
> 
> What is the reason for dropping this particular variable ? How can I get
> the value of this variable from within Emacs ?

The process that starts your Emacs has to pass it on (that's the idea
of environment variables). If things changed, this is where you have
to look.

How is your Emacs started?

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Some environment variables disappeared for getenv
  2022-09-15 12:53 ` tomas
@ 2022-09-15 13:28   ` Julien Cubizolles
  2022-09-15 19:17     ` Iñigo Serna
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Cubizolles @ 2022-09-15 13:28 UTC (permalink / raw)
  To: emacs-devel

<tomas@tuxteam.de> writes:

> On Thu, Sep 15, 2022 at 01:12:02PM +0200, Julien Cubizolles wrote:
>> I used to rely on getenv to get the value of $XDG_SESSION_TYPE. I
>> noticed that recently:
>> --8<---------------cut here---------------start------------->8---
>> (getenv "XDG_SESSION_TYPE")
>> --8<---------------cut here---------------end--------------->8---
>> returns nil, because this variable isn't in process-environment
>> 
>> What is the reason for dropping this particular variable ? How can I get
>> the value of this variable from within Emacs ?
>
> The process that starts your Emacs has to pass it on (that's the idea
> of environment variables). If things changed, this is where you have
> to look.
>
> How is your Emacs started?

It's started through a user systemd service that hasn't changed in
years.

--8<---------------cut here---------------start------------->8---
[Service]
Type=forking
Environment='XMODIFIERS=""'
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook daemon-kill-emacs-hook) (kill-emacs))"
Restart=on-failure
Environment="DISPLAY=:%i"
TimeoutStartSec=0
--8<---------------cut here---------------end--------------->8---

In the getenv docstring, there is a mention of variable
process-environment, containing a list of environment variables, not
refered to in the systemd service file but nonetheless accessible to
getenv (some are XDG variables like XDG_DATA_DIRS). Maybe
XDG_SESSION_TYPE has been dropped from this list ?


-- 
Julien Cubizolles




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Some environment variables disappeared for getenv
  2022-09-15 13:28   ` Julien Cubizolles
@ 2022-09-15 19:17     ` Iñigo Serna
  0 siblings, 0 replies; 4+ messages in thread
From: Iñigo Serna @ 2022-09-15 19:17 UTC (permalink / raw)
  To: Julien Cubizolles; +Cc: emacs-devel

Hi,

> [...]
> It's started through a user systemd service that hasn't changed 
> in
> years.

You could add more new "Enviroment" lines to your systemd unit 
file, f.e.

    Environment=XDG_SESSION_TYPE=wayland

Best regards,
Iñigo

On 15 September 2022 at 15:28 +02, Julien Cubizolles 
<j.cubizolles@free.fr> wrote:

> <tomas@tuxteam.de> writes:
>
>> On Thu, Sep 15, 2022 at 01:12:02PM +0200, Julien Cubizolles 
>> wrote:
>>> I used to rely on getenv to get the value of 
>>> $XDG_SESSION_TYPE. I
>>> noticed that recently:
>>> --8<---------------cut 
>>> here---------------start------------->8---
>>> (getenv "XDG_SESSION_TYPE")
>>> --8<---------------cut 
>>> here---------------end--------------->8---
>>> returns nil, because this variable isn't in 
>>> process-environment
>>> 
>>> What is the reason for dropping this particular variable ? How 
>>> can I get
>>> the value of this variable from within Emacs ?
>>
>> The process that starts your Emacs has to pass it on (that's 
>> the idea
>> of environment variables). If things changed, this is where you 
>> have
>> to look.
>>
>> How is your Emacs started?
>
> It's started through a user systemd service that hasn't changed 
> in
> years.
>
> --8<---------------cut 
> here---------------start------------->8---
> [Service]
> Type=forking
> Environment='XMODIFIERS=""'
> ExecStart=/usr/bin/emacs --daemon
> ExecStop=/usr/bin/emacsclient --eval "(progn (setq 
> kill-emacs-hook daemon-kill-emacs-hook) (kill-emacs))"
> Restart=on-failure
> Environment="DISPLAY=:%i"
> TimeoutStartSec=0
> --8<---------------cut 
> here---------------end--------------->8---
>
> In the getenv docstring, there is a mention of variable
> process-environment, containing a list of environment variables, 
> not
> refered to in the systemd service file but nonetheless 
> accessible to
> getenv (some are XDG variables like XDG_DATA_DIRS). Maybe
> XDG_SESSION_TYPE has been dropped from this list ?


-- 
Iñigo Serna



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-15 19:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15 11:12 Some environment variables disappeared for getenv Julien Cubizolles
2022-09-15 12:53 ` tomas
2022-09-15 13:28   ` Julien Cubizolles
2022-09-15 19:17     ` Iñigo Serna

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).