[systemd-devel] user environment variables

2014-12-05 Thread arnaud gaboury
Dear all,

For the user services started by systemctl --user, I sometimes need to
tell systemd some environment variables values.

For this purpose, I use drop-in configuration files (MyService.conf)
in /etc/systemd/system/user@.service.d

I am wondering if there is another way to pass the variables values.
I was thinking to some user directory like this :
~/.config/systemd/user@.service.d (does not work) or import one only
file with all these variables values with this command at session
start up: systemctl --import-environment FILE (does not work), or
maybe something like systemctl --import-environment 'cat FILE'.

Thank you for any hint.

Regards.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-12-05 Thread Lennart Poettering
On Fri, 05.12.14 14:13, arnaud gaboury (arnaud.gabo...@gmail.com) wrote:

 Dear all,
 
 For the user services started by systemctl --user, I sometimes need to
 tell systemd some environment variables values.
 
 For this purpose, I use drop-in configuration files (MyService.conf)
 in /etc/systemd/system/user@.service.d
 
 I am wondering if there is another way to pass the variables values.
 I was thinking to some user directory like this :
 ~/.config/systemd/user@.service.d (does not work) or import one only
 file with all these variables values with this command at session
 start up: systemctl --import-environment FILE (does not work), or
 maybe something like systemctl --import-environment 'cat FILE'.

systemctl set-environment `cat FILE` should work, no?

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-12-05 Thread arnaud gaboury

 systemctl set-environment `cat FILE` should work, no?

 Lennart


I am messing with it.


$ systemctl --user set-environment toto=3 tata=4
$ systemctl --user show-environment
..
tata=4
toto=3
-

Now:
--
$ echo 'lolo=4 lala=5' | tee test
lolo=4 lala=5
$ systemctl --user set-environment 'cat test'
Failed to set environment: Invalid environment assignments
---

No idea what I do wrong.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-12-05 Thread Daniele Nicolodi
On 05/12/14 16:13, arnaud gaboury wrote:
 Now:
 --
 $ echo 'lolo=4 lala=5' | tee test
 lolo=4 lala=5
 $ systemctl --user set-environment 'cat test'
 Failed to set environment: Invalid environment assignments
 ---
 
 No idea what I do wrong.

This is invalid shell syntax. This should work:

$ systemctl --user set-environment `cat test`

or, if you are using bash, I find this more readable:

$ systemctl --user set-environment $(cat test)


Cheers,
Daniele

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-12-05 Thread arnaud gaboury

 $ systemctl --user set-environment `cat test`

Damned. Thank you
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-12-05 Thread Mantas Mikulėnas
On Fri, Dec 5, 2014 at 5:20 PM, Daniele Nicolodi dani...@grinta.net wrote:

 On 05/12/14 16:13, arnaud gaboury wrote:
  Now:
  --
  $ echo 'lolo=4 lala=5' | tee test
  lolo=4 lala=5
  $ systemctl --user set-environment 'cat test'
  Failed to set environment: Invalid environment assignments
  ---
 
  No idea what I do wrong.

 This is invalid shell syntax. This should work:

 $ systemctl --user set-environment `cat test`

 or, if you are using bash, I find this more readable:

 $ systemctl --user set-environment $(cat test)


As the variables sometimes have spaces, this might be more reliable:

xargs systemctl --user set-environment  test

(With -d '\n' or without, depending on chosen syntax.)

It's possible to emulate import-environment using:

xargs -d '\0' systemctl --user set-environment  /proc/self/environ

-- 
Mantas Mikulėnas graw...@gmail.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-11-15 Thread Andrei Borzenkov
В Mon, 10 Nov 2014 20:55:12 +0100
arnaud gaboury arnaud.gabo...@gmail.com пишет:

  As for the variable, two more wishes (not a big deal yet):
  - in units, why not add a specifier reflecting $XDG_CONFIG_HOME
 
  Hmm, when we start with that, then I figure people want the other XDG
  dirs as well, soon...
 
  Anyway, what's the usecase for this?
 
 Just laziness when writing service files.conf
 Ex: gpg-agent.conf
 [Service]
 Environment=GNUPGHOME=%h/.config/gnupg
 
 I often use the path sequence '%h/.config'.
 So forget about it, laziness is not a valuable reason
 

I do not think it is laziness. If it was necessary to abstract
%h/.config as separate variable in standard definition, then we should
expect the path may change. In which case it makes a difference whether
we need to change it single place or in every unit.

Some XDG directories did move around in the past.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-11-10 Thread Lennart Poettering
On Fri, 07.11.14 20:40, arnaud gaboury (arnaud.gabo...@gmail.com) wrote:

 
  We could probably at least open up DefaultEnvironment= to specifier
  expansion, so that %t would work the same way as in unit files. I
  added a TODO list item for this now.
 
 
 Thank you so much  This refers to the recent flame about systemd.
 As a newbie, I can testify the dev team is doing everything to help.
 
 As for the variable, two more wishes (not a big deal yet):
 - in units, why not add a specifier reflecting $XDG_CONFIG_HOME

Hmm, when we start with that, then I figure people want the other XDG
dirs as well, soon...

Anyway, what's the usecase for this?

 - why not systemctl --export-environment

Same here, what's the usecase?

(Not really opposed to either, but I'd like to hear a usecase first)

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-11-10 Thread arnaud gaboury
 As for the variable, two more wishes (not a big deal yet):
 - in units, why not add a specifier reflecting $XDG_CONFIG_HOME

 Hmm, when we start with that, then I figure people want the other XDG
 dirs as well, soon...

 Anyway, what's the usecase for this?

Just laziness when writing service files.conf
Ex: gpg-agent.conf
[Service]
Environment=GNUPGHOME=%h/.config/gnupg

I often use the path sequence '%h/.config'.
So forget about it, laziness is not a valuable reason



 - why not systemctl --export-environment

 Same here, what's the usecase?

No usecase at the moment. I can imagine one day a systemctl started
service with an exported variable to systemd env and then need to pass
the variable to the user env for any other services.
Again, not yet a big deal.


 (Not really opposed to either, but I'd like to hear a usecase first)

 Lennart

 --
 Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-11-07 Thread arnaud gaboury

 We could probably at least open up DefaultEnvironment= to specifier
 expansion, so that %t would work the same way as in unit files. I
 added a TODO list item for this now.


Thank you so much  This refers to the recent flame about systemd.
As a newbie, I can testify the dev team is doing everything to help.

As for the variable, two more wishes (not a big deal yet):
- in units, why not add a specifier reflecting $XDG_CONFIG_HOME
- why not systemctl --export-environment

Unfortunately I can't contribute to your code.

Keep your good work and thanks for being here in the linux world.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] user environment variables

2014-11-06 Thread Lennart Poettering
On Fri, 31.10.14 17:16, arnaud gaboury (arnaud.gabo...@gmail.com) wrote:

 For systemd be aware of certain environment variables, I usually use a
 drop-in config in /etc/systemd/system/user@service.d. This way, I can
 see the varibale when running
 $ systemctl --user show-environment
 
 Now I am wondering why not using the /etc/systemd/user.conf for these
 variables. I tried this:
 
 ..
 DefaultEnvironment=DISPLAY=:0
 RXVT_SOCKET=$XDG_RUNTIME_DIR/urxvt-hortensia TOTO=me
 
 
 Unfortunately,
 -
 gabx@hortensia ➤➤ ~ % systemctl --user show-environment
 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/dbus/user_bus_socket
 DISPLAY=:0
 TOTO=me
 HOME=/home/gabx
 LANG=en_US.UTF-8
 LC_COLLATE=C
 LOGNAME=gabx
 MAIL=/var/spool/mail/gabx
 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
 RXVT_SOCKET=$XDG_RUNTIME_DIR/urxvt-hortensia
 SHELL=/usr/bin/zsh
 USER=gabx
 XDG_RUNTIME_DIR=/run/user/1000
 
 
 the path is not recognized, even if XDG_RUNTIME_DIR is a known
 variable. Please note that DISPLAY and TOTO are recognized
 
 I am wondering what I am doing wrong with RXVT_SOCKET ?

When systemd parses user.conf it does not resolve env vars in the shel
$foo syntax. In fact we don't do that for almost any field, except
ExecStart= and friends really.

We could probably at least open up DefaultEnvironment= to specifier
expansion, so that %t would work the same way as in unit files. I
added a TODO list item for this now.

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel