summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSisiutl <sisiutl@egregore.fun>2024-11-27 16:43:59 +0100
committerSisiutl <sisiutl@egregore.fun>2024-11-27 16:43:59 +0100
commited33e6245249d350e82110d07586e40ee0346982 (patch)
tree13066854bab32cd4d568428bb0c9c276fa6f9d06
parent15af28779fcea0a44f2b17723609468ee4f74e6e (diff)
hyprland real service
-rw-r--r--sigils/home/services/hyprland.scm72
1 files changed, 27 insertions, 45 deletions
diff --git a/sigils/home/services/hyprland.scm b/sigils/home/services/hyprland.scm
index 3b230a5..874b875 100644
--- a/sigils/home/services/hyprland.scm
+++ b/sigils/home/services/hyprland.scm
@@ -227,7 +227,7 @@
(hypr-config %default-hyprland-config)
"Hyprland configuration")
(tries
- (number 10)
+ (number 15)
"Polls Hyprland up to TRIES."))
(define (hyprland-configuration->file config)
@@ -250,21 +250,20 @@
(provision '(hyprland
wayland-display))
(modules '((ice-9 ftw)
- (ice-9 match)
(ice-9 regex)
- (ice-9 receive)
- (srfi srfi-1)))
+ (ice-9 match)
+ (srfi srfi-1)
+ (shepherd support)))
+ (respawn? #t)
+ (respawn-limit (home-hyprland-configuration-tries config))
+ (respawn-delay 1)
(start
#~(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")
- (string-append "/run/user" (getuid))))
+ (env-hyprland-instance (getenv "HYPRLAND_INSTANCE_SIGNATURE"))
+ (env-wayland-display (getenv "WAYLAND_DISPLAY")))
(define hypr-directory
- (string-append xdg-runtime-directory "/hypr"))
+ (string-append %user-runtime-dir "/hypr"))
(define (socket? directory regex)
(find (match-lambda
@@ -276,48 +275,31 @@
(access? name O_RDWR)))))
(or (scandir directory) '())))
- (define (find-instance tries)
- ;; Wait for an accessible socket to show up in
- ;; XDG-RUNTIME-DIRECTORY, up to TRIES tries.
- (let loop ((attempts tries))
-
- (define instance-signature
- (or instance
- (socket? hypr-directory "_[0-9]+_[0-9]+")))
-
- (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)
- (format (current-error-port)
- "Hyprland did not show up; giving up.\n")
- (begin
- (sleep 1)
- (loop (- attempts 1)))))
-
- (values instance-signature wayland-display)))
-
- (receive (instance display)
- (find-instance tries)
- (when (and instance display)
+ (define hyprland-instance
+ (or env-hyprland-instance
+ (socket? hypr-directory "_[0-9]+_[0-9]+")))
+
+ (define wayland-display
+ (or env-wayland-display
+ (socket? %user-runtime-dir "wayland-[0-9]+")))
+
+ (let ((found? (and wayland-display hyprland-instance)))
+ (when found?
+ (format #t "Hyprland instance found at ~s \
+with wayland display ~s.~%" hyprland-instance wayland-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" display)
- #t))))
+ (setenv "HYPRLAND_INSTANCE_SIGNATURE" hyprland-instance)
+ (setenv "WAYLAND_DISPLAY" wayland-display))
+ found?)))
(stop #~(lambda (_)
(unsetenv "HYPRLAND_INSTANCE_SIGNATURE")
(unsetenv "WAYLAND_DISPLAY")
- #f))
- (respawn? #f))))
+ #f)))))
+
(define home-hyprland-service-type
(service-type