engstrand-config / home-service-dwl-guile

GNU Guix home service for the dwl window manager with dynamic configuration in Guile Scheme
GNU General Public License v3.0
35 stars 3 forks source link

Shepherd service does not inherit environment variables #19

Open luishgh opened 3 weeks ago

luishgh commented 3 weeks ago

I'm trying to use dwl-guile with Guix Home inside a Void Linux installation. When I start it with herd start dwl-guile, it does not inherit the environment variables from the tty session nor loads ~/.profile. If I start it manually, it works. Is this intended? If so, how could I load the profile upon launch? I use it to load additional Guix profiles like shown here.

My current config:

(define dwl-configuration
  (home-dwl-guile-configuration
    (package
      (patch-dwl-guile-package dwl-guile
                               #:patches (list %patch-xwayland)))
    (environment-variables 
      `(("XDG_CURRENT_DESKTOP" . "dwl")
        ("XDG_SESSION_TYPE" . "wayland")
        ("MOZ_ENABLE_WAYLAND" . "1")
        ("ELM_ENGINE" . "wayland_egl")
        ("ECORE_EVAS_ENGINE" . "wayland-egl")
        ("_JAVA_AWT_WM_NONREPARENTING" . "1")))
    (auto-start? #f)
    (native-qt? #f)
    (config
      `(((setq inhibit-defaults? #t)
         (dwl:start-repl-server)
         (setq tags (map number->string (iota 9 1)))
         (dwl:set-tty-keys "C-M")
         (dwl:set-tag-keys "s" "s-S")
         (set-keys "s-<space>" 'dwl:toggle-floating
                   "s-<return>" '(dwl:spawn "foot")
                   "s-p" '(dwl:spawn "bemenu-run")
                   "s-e" '(dwl:spawn "emacsclient" "-c")
                   "s-j" '(dwl:focus-stack 1)
                   "s-k" '(dwl:focus-stack -1)
                   "s-l" '(dwl:change-master-factor 0.05)
                   "s-h" '(dwl:change-master-factor -0.05)
                   "s-<page-up>" '(dwl:change-masters 1)
                   "s-<page-down>" '(dwl:change-masters -1)
                   "s-t" '(dwl:cycle-layout 1)
                   "s-<left>" '(dwl:focus-monitor 'DIRECTION-LEFT)
                   "s-<right>" '(dwl:focus-monitor 'DIRECTION-RIGHT)
                   "s-<up>" '(dwl:focus-monitor 'DIRECTION-UP)
                   "s-<down>" '(dwl:focus-monitor 'DIRECTION-DOWN)
                   "s-S-<left>" '(dwl:tag-monitor 'DIRECTION-LEFT)
                   "s-S-<right>" '(dwl:tag-monitor 'DIRECTION-RIGHT)
                   "s-S-<up>" '(dwl:tag-monitor 'DIRECTION-UP)
                   "s-S-<down>" '(dwl:tag-monitor 'DIRECTION-DOWN)
                   "s-S-c" 'dwl:kill-client
                   "s-<tab>" 'dwl:view
                   "s-S-0" '(dwl:view 0) ;; 0 will show all tags
                   "s-f" 'dwl:toggle-fullscreen
                   "S-s-q" 'dwl:quit
                   "s-<mouse-left>" 'dwl:move
                   "s-<mouse-middle>" 'dwl:toggle-floating
                   "s-<mouse-right>" 'dwl:resize)
         (set-layouts 'default "[]=" 'dwl:tile
                      'monocle "|M|" 'dwl:monocle)
         ;; Launch helpful programs after init
         (add-hook! dwl:hook-startup
                    (lambda ()
                      ;(dwl:spawn "setxkbmap" "-option" "ctrl:nocaps")
                      (dwl:spawn "dunst")
                      ;(dwl:spawn "nm-applet" "--indicator")
                      (dwl:spawn "dtao-guile" "-c" ".config/dtao-guile/config.scm")
                      (dwl:spawn "emacs" "--daemon"))))))))
Frewacom commented 2 weeks ago

Hm, I think this is caused by Shepherd spawning dwl-guile in a new environment that is different from the one which you spawn it from (not sure, though). However, I don't think this should be the default behaviour, and it is almost certainly not the behaviour you would expect as a user.

I am not quite sure what the best way of loading the environment variables is, or if there even is a good solution in this case. I suppose the temporary fix is to just spawn it manually instead of using Shepherd, as you said.