From 13a1346c39c4de5523a91832301ad9dc27b6354c Mon Sep 17 00:00:00 2001 From: Milarin Date: Thu, 12 Dec 2024 20:35:28 +0100 Subject: [PATCH] check reachability once at method call --- check_reachable.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/check_reachable.go b/check_reachable.go index 1bde33b..dac709c 100644 --- a/check_reachable.go +++ b/check_reachable.go @@ -21,6 +21,10 @@ func (c *Client) IsReachable() bool { // and returns true as soon as IsReachable returns true. // When ctx is closed before Hyprland is reachable, false is returned func (c *Client) WaitUntilReachable(ctx context.Context) bool { + if c.IsReachable() { + return true + } + ticker := time.NewTicker(100 * time.Millisecond) defer ticker.Stop()