diff options
-rw-r--r-- | sigils/home/services/hyprland.scm | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/sigils/home/services/hyprland.scm b/sigils/home/services/hyprland.scm index c670b04..3b230a5 100644 --- a/sigils/home/services/hyprland.scm +++ b/sigils/home/services/hyprland.scm @@ -252,9 +252,12 @@ (modules '((ice-9 ftw) (ice-9 match) (ice-9 regex) + (ice-9 receive) (srfi srfi-1))) (start - #~(lambda* (#:optional (instance (getenv "HYPRLAND_INSTANCE_SIGNATURE"))) + #~(lambda* (#:optional + (instance (getenv "HYPRLAND_INSTANCE_SIGNATURE")) + (display (getenv "WAYLAND_DISPLAY"))) (define tries #$(home-hyprland-configuration-tries config)) (define xdg-runtime-directory (or (getenv "XDG_RUNTIME_DIR") @@ -279,34 +282,37 @@ (let loop ((attempts tries)) (define instance-signature - (socket? hypr-directory "_[0-9]+_[0-9]+")) + (or instance + (socket? hypr-directory "_[0-9]+_[0-9]+"))) - (if instance-signature - (begin - (format #t "Hyprland instance found at ~s.~%" - instance-signature) - instance-signature) + (define wayland-display + (or display + (socket? xdg-runtime-directory "wayland-[0-9]+"))) + + (if (and instance-signature wayland-display) + (format #t "Hyprland instance found at ~s \ +with wayland display ~s.~%" + instance-signature wayland-display) (if (zero? attempts) - (begin - (format (current-error-port) - "Hyprland did not show up; \ -giving up.\n") - #f) + (format (current-error-port) + "Hyprland did not show up; giving up.\n") (begin (sleep 1) - (loop (- attempts 1))))))) + (loop (- attempts 1))))) + + (values instance-signature wayland-display))) - (let ((instance (or instance (find-instance tries)))) - (when instance + (receive (instance display) + (find-instance tries) + (when (and instance display) ;; Note: 'make-forkexec-constructor' calls take their ;; default #:environment-variables value before this service ;; is started and are thus unaffected by the 'setenv' call ;; below. Users of this service have to explicitly query ;; its value. (setenv "HYPRLAND_INSTANCE_SIGNATURE" instance) - (setenv "WAYLAND_DISPLAY" - (socket? xdg-runtime-directory "wayland-[0-9]+"))) - instance))) + (setenv "WAYLAND_DISPLAY" display) + #t)))) (stop #~(lambda (_) (unsetenv "HYPRLAND_INSTANCE_SIGNATURE") (unsetenv "WAYLAND_DISPLAY") |