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. >> some weird state) before the graphical session is ready or end up >> hindering the process of ending a graphical session. Systemd does this >> with `graphical-session.target`, somehow. (I think this stackoverflow >> answer[3] implies that `graphical-session.target` is launched when the >> services for specific graphical sessions are launched--but how are those >> launched?) > > For GNOME, GDM starts the GNOME (wayland or x11) desktop file which > starts some gnome-session binary which starts the systemd services. > >> Anyways, shepherd does not have to be simply an >> implementation of ANSI systemd. Perhaps we could bind a service to a >> session by wrapping the `Exec=` call in the session's .desktop file? >> >> Let me know your ideas, >> >> Andrew >> >> [1] https://specifications.freedesktop.org/autostart-spec/latest/ >> >> [2]https://systemd.io/DESKTOP_ENVIRONMENTS/#xdg-autostart-integration >> >> [3] >> https://unix.stackexchange.com/questions/787236/how-exactly-does-graphical-session-target-start-or-get-started > > Hi Andrew, > > This will be something I will have to do for the Shepherdification of > GNOME session[1]. > > I think its a good idea to read the desktop files and generate the > services automatically after the start of the graphical-session > service. Some things are still blurry but we can figure it out. > > If you want to code that part, please let me know! > > Have a nice day, > Noé > > [1] https://gitlab.gnome.org/noe/gnomeherd/-/tree/main/shepherd?ref_type=heads