Hilton Chain <hako@ultrarare.space> writes:

> Noé Lopez <noelo...@free.fr> writes:
>
>> Andrew Wong <wonga...@icloud.com> writes:
>>
>>> Hello Guix,
>>>
>>> How would Guix/Shepherd implement the XDG Autostart specification[1]?
>>>
>>> I looked into how systemd does it[2], and it appears that implementation
>>> is done by having a service generate other services based on the
>>> .desktop files in the correct directory. Is an
>>> `autostart-service-generator-service-type` possible in this way? Or,
>>> perhaps the most rudimentary implementation would be a service that just
>>> runs `dex -a` once a session is started.
>
> I think there can be a library to parse desktop files and we can use it in the
> init file created by home-shepherd-service-type.
>
>>> On that note, a prerequisite to correct behavior for autostarts seems to
>>> be a service (or other mechanism) that starts and stops with a graphical
>>> session, so that the applications don't launch and fail (or get into
>
> For the graphical session, I investigated the current home-x11-service-type
> implementation in <https://issues.guix.gnu.org/76619#8>.
>
> Since we don't have a way to pass environment variables, home-shepherd 
> inherits
> the starting environment.  For a graphical session, home-shepherd should be
> started in a environment with DISPLAY or WAYLAND_DISPLAY.
>
> I'm not sure if we can have the environment variables when starting from a
> display manager.  In my environment WAYLAND_DISPLAY is only available when
> starting the window manager so I disabled auto-starting of Shepherd:
>
> --8<---------------cut here---------------start------------->8---
> (service home-shepherd-service-type
>   (home-shepherd-configuration
>     (auto-start? #f)
>     (daemonize? #f)))
> --8<---------------cut here---------------end--------------->8---
>
> Setting daemonize? to #f will allow Shepherd to shut down itself after exiting
> the window manager.
>
> Since the socket file may be removed (together with $XDG_RUNTIME_DIR) when
> logged out, I personally start Shepherd using the following command to prevent
> starting multiple instances, not sure if something similar can be implemented 
> in
> Guix Home:
>
> --8<---------------cut here---------------start------------->8---
> $ pgrep --uid $USER shepherd > /dev/null || shepherd
> --8<---------------cut here---------------end--------------->8---
>
>
>
> In my investigation my conclusion is that, we can have a graphical session
> target like the following:
>
> --8<---------------cut here---------------start------------->8---
> (service home-graphical-session-service-type
>   (home-graphical-session-configuration
>     ;; Check for $WAYLAND_DISPLAY, fail when non-existent.
>     (wayland? #t)
>     ;; Check for $DISPLAY, fail when non-existent.
>     (x11? #t)))
> --8<---------------cut here---------------end--------------->8---
>
> Services can depend on its symbol, graphical-session and explicitly 
> x11-display
> or wayland-display.  The service will fail to start when starting Shepherd in
> TTY environment and block dependent services.
>
> The limitation is that we still don't have a way to import environment 
> variables
> and we can't manage two graphical sessions at the same time.

turnstile[1], which aims to replace the session manager part of elogind, might
be a good fit to start Shepherd because it provides "a service-manager-agnostic
way to manage per-user service managers for user services"

Void Linux has turnstile in their documentation[2] so I assume it's usable.

[1]: https://github.com/chimera-linux/turnstile
[2]: https://docs.voidlinux.org/config/session-management.html#turnstile

Reply via email to