summaryrefslogtreecommitdiff
path: root/sigils/home
diff options
context:
space:
mode:
authorSisiutl <sisiutl@egregore.fun>2024-11-25 02:44:05 +0100
committerSisiutl <sisiutl@egregore.fun>2024-11-25 05:07:31 +0100
commit88a556aaadd1b692798f6092ce948730936575f5 (patch)
tree6e8f7d5beb6809d55014998e056ae7c78046a37c /sigils/home
parentdb09d31dc63c44a23f8e8bf9c6906ffd607ecca6 (diff)
add wayland_display check
Diffstat (limited to 'sigils/home')
-rw-r--r--sigils/home/services/hyprland.scm42
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")