# hypr/connect Connect to Hyprland's two IPC sockets (event socket + command socket). The sockets are non-blocking and serviced by the VM event loop, so subscriptions and calls can follow immediately. ## Syntax
[hypr/connect ?opts]
## Parameters - `$opts` — optional map: - `:events-socket` — unix path for events, or `"tcp:host:port"` (tests) - `:commands-socket` — unix path for commands, or `"tcp:host:port"` Defaults to `$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock` (events) and `.socket.sock` (commands). ## Examples
set h [hypr/connect]
set fake [hypr/connect %{ :events-socket "tcp:127.0.0.1:7400"
                          :commands-socket "tcp:127.0.0.1:7401" }]
## Returns A `hypr_conn` native resource, or `%Err{:message}` when the instance signature is unset (`"cannot locate hyprland sockets (set` $HYPRLAND_INSTANCE_SIGNATURE ...)"`) or either socket refuses the` connection. ## See Also `hypr/call`, `hypr/subscribe`, `hypr/info`