Post by Max NikulinI have naively tried
cat ~/.config/systemd/user/service.d/umask.conf
[Service]
UMask=0007
umask
0007
OK. Let's follow this path a bit.
I googled "how to create a systemd user service" and got
<https://blog.victormendonca.com/2018/05/14/creating-a-simple-systemd-user-service/>.
Starting from there:
hobbit:~$ cd .config
hobbit:~/.config$ mkdir -p systemd/user
hobbit:~/.config$ vi systemd/user/xterm.service
hobbit:~/.config$ cat systemd/user/xterm.service
[Unit]
Description=Try to run an xterm
[Service]
Type=simple
StandardOutput=journal
ExecStart=/usr/bin/xterm
[Install]
WantedBy=default.target
hobbit:~/.config$ systemctl --user enable xterm.service
Created symlink /home/greg/.config/systemd/user/default.target.wants/xterm.service → /home/greg/.config/systemd/user/xterm.service.
hobbit:~/.config$ systemctl --user start xterm.service
This caused an xterm to popup. OK, so far so good. Apparently the
systemd --user process inherits my $DISPLAY, so it's able to launch an
xterm.
I closed the xterm, and then:
hobbit:~$ cd ~/.config/systemd
hobbit:~/.config/systemd$ ls
user/
hobbit:~/.config/systemd$ ls user
default.target.wants/ xterm.service
hobbit:~/.config/systemd$ cd user
hobbit:~/.config/systemd/user$ mkdir service.d
hobbit:~/.config/systemd/user$ vi service.d/umask.conf
hobbit:~/.config/systemd/user$ cat service.d/umask.conf
[Service]
UMask=0007
Then:
hobbit:~$ systemctl --user start xterm.service
I ran umask within this xterm, and got 0022. Next:
hobbit:~$ systemctl --user daemon-reload
hobbit:~$ systemctl --user start xterm.service
This time, umask gave me 0007.
So it looks like your technique works, allowing an end user to create a
systemd --user configuration file which affects all(?) of their
systemd --user services, if they have any.
I also performed this experiment:
hobbit:~$ vi .config/systemd/user/service.d/env.conf
hobbit:~$ cat .config/systemd/user/service.d/env.conf
[Service]
Environment="FOO=%h/test123" "BAR=b a r"
hobbit:~$ systemctl --user daemon-reload
hobbit:~$ systemctl --user start xterm.service
The resulting xterm had umask 0007, and the expected values in the FOO
and BAR environment variables (with %h expanded to my home directory,
as documented in systemd.unit(5)).
I'm assuming the two files in service.d/ can be merged, but I didn't
test that.
So, this is a highly positive result. (And surprising. Why isn't this
stuff documented in ALL the places??) It looks like there's a chance
that some Desktop Environments can be configured by end users after all.
Now we just need for GNOME users to discover a way to configure the
programs that are started as children of dbus, and then we can move
forward. Documentation would be my top priority. If other people want
to try to drum up interest in environment configuration, then there'll
be documentation available for end users to follow.