Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
13a1346c39 | |||
5e1ba06ebe | |||
2b5b3f84cb |
@ -21,6 +21,10 @@ func (c *Client) IsReachable() bool {
|
|||||||
// and returns true as soon as IsReachable returns true.
|
// and returns true as soon as IsReachable returns true.
|
||||||
// When ctx is closed before Hyprland is reachable, false is returned
|
// When ctx is closed before Hyprland is reachable, false is returned
|
||||||
func (c *Client) WaitUntilReachable(ctx context.Context) bool {
|
func (c *Client) WaitUntilReachable(ctx context.Context) bool {
|
||||||
|
if c.IsReachable() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
ticker := time.NewTicker(100 * time.Millisecond)
|
ticker := time.NewTicker(100 * time.Millisecond)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ func WaitForDefaultClient(ctx context.Context) (*Client, error) {
|
|||||||
func WaitForClient(ctx context.Context, signature string) (*Client, error) {
|
func WaitForClient(ctx context.Context, signature string) (*Client, error) {
|
||||||
lockFilePath := fmt.Sprintf("/run/user/1000/hypr/%s/hyprland.lock", signature)
|
lockFilePath := fmt.Sprintf("/run/user/1000/hypr/%s/hyprland.lock", signature)
|
||||||
|
|
||||||
lockFileExists := !waitFor(ctx, func() bool {
|
lockFileExists := waitFor(ctx, func() bool {
|
||||||
_, err := os.Stat(lockFilePath)
|
_, err := os.Stat(lockFilePath)
|
||||||
return !errors.Is(err, os.ErrNotExist)
|
return !errors.Is(err, os.ErrNotExist)
|
||||||
})
|
})
|
||||||
@ -96,7 +96,7 @@ func WaitForClient(ctx context.Context, signature string) (*Client, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.WaitUntilReachable(context.Background()) {
|
if !client.WaitUntilReachable(context.Background()) {
|
||||||
return nil, errors.New("hyprland not reachable")
|
return nil, errors.New("hyprland not reachable")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user