2024-02-20 21:16:07 +01:00
---
weight: 9
title: IPC
---
2022-08-12 20:46:36 +02:00
Hyprland exposes 2 UNIX Sockets, for controlling / getting info about Hyprland
via code / bash utilities.
2024-02-20 21:16:07 +01:00
## Hyprland Instance Signature (HIS)
2022-08-12 20:46:36 +02:00
2022-08-13 19:06:18 +02:00
```sh
2022-08-12 20:46:36 +02:00
echo $HYPRLAND_INSTANCE_SIGNATURE
```
2024-02-20 21:16:07 +01:00
## /tmp/hypr/\[HIS\]/.socket.sock
2022-08-12 20:46:36 +02:00
Used for hyprctl-like requests. See the
2024-03-17 13:44:39 +01:00
[Hyprctl page ](../Configuring/Using-hyprctl ) for commands.
2022-08-12 20:46:36 +02:00
2023-02-02 12:29:32 +01:00
basically, write `[flag(s)]/command args` .
2022-08-12 20:46:36 +02:00
2024-02-20 21:16:07 +01:00
## /tmp/hypr/\[HIS\]/.socket2.sock
2022-08-12 20:46:36 +02:00
Used for events. Hyprland will write to each connected client live events like
this:
2022-10-12 17:08:11 +02:00
`EVENT>>DATA\n` (`\n` is a linebreak)
2022-08-12 20:46:36 +02:00
e.g.: `workspace>>2`
2024-02-20 21:16:07 +01:00
## Events list
2022-08-12 20:46:36 +02:00
2022-08-18 17:22:14 +02:00
| name | description | data |
| --- | --- | --- |
| workspace | emitted on workspace change. Is emitted ONLY when a user requests a workspace change, and is not emitted on mouse movements (see `activemon` ) | `WORKSPACENAME` |
2024-03-08 18:39:58 +01:00
| workspacev2 | emitted on workspace change. Is emitted ONLY when a user requests a workspace change, and is not emitted on mouse movements (see `activemon` ) | `WORKSPACEID,WORKSPACENAME` |
2022-08-18 17:22:14 +02:00
| focusedmon | emitted on the active monitor being changed. | `MONNAME,WORKSPACENAME` |
| activewindow | emitted on the active window being changed. | `WINDOWCLASS,WINDOWTITLE` |
2023-02-06 14:17:44 +01:00
| activewindowv2 | emitted on the active window being changed. | `WINDOWADDRESS` |
2022-08-18 17:22:14 +02:00
| fullscreen | emitted when a fullscreen status of a window changes. | `0/1` (exit fullscreen / enter fullscreen) |
| monitorremoved | emitted when a monitor is removed (disconnected) | `MONITORNAME` |
| monitoradded | emitted when a monitor is added (connected) | `MONITORNAME` |
2024-02-15 15:22:44 +01:00
| monitoraddedv2 | emitted when a monitor is added (connected) | `MONITORID,MONITORNAME,MONITORDESCRIPTION` |
2022-08-18 17:22:14 +02:00
| createworkspace | emitted when a workspace is created | `WORKSPACENAME` |
2024-03-08 18:39:58 +01:00
| createworkspacev2 | emitted when a workspace is created | `WORKSPACEID,WORKSPACENAME` |
2022-08-18 17:22:14 +02:00
| destroyworkspace | emitted when a workspace is destroyed | `WORKSPACENAME` |
2024-03-08 18:39:58 +01:00
| destroyworkspacev2 | emitted when a workspace is destroyed | `WORKSPACEID,WORKSPACENAME` |
2022-08-26 16:06:00 +02:00
| moveworkspace | emitted when a workspace is moved to a different monitor | `WORKSPACENAME,MONNAME` |
2024-03-08 18:39:58 +01:00
| moveworkspacev2 | emitted when a workspace is moved to a different monitor | `WORKSPACEID,WORKSPACENAME,MONNAME` |
2023-09-05 15:56:19 +02:00
| renameworkspace | emitted when a workspace is renamed | `WORKSPACEID,NEWNAME` |
2023-09-04 16:45:18 +02:00
| activespecial | emitted when the special workspace opened in a monitor changes (closing results in an empty `WORKSPACENAME` ) | `WORKSPACENAME,MONNAME` |
2022-08-18 17:51:17 +02:00
| activelayout | emitted on a layout change of the active keyboard | `KEYBOARDNAME,LAYOUTNAME` |
2022-08-21 17:23:55 +02:00
| openwindow | emitted when a window is opened | `WINDOWADDRESS` ,`WORKSPACENAME`,`WINDOWCLASS`,`WINDOWTITLE` |
| closewindow | emitted when a window is closed | `WINDOWADDRESS` |
| movewindow | emitted when a window is moved to a workspace | `WINDOWADDRESS` ,`WORKSPACENAME` |
2024-03-08 18:39:58 +01:00
| movewindowv2 | emitted when a window is moved to a workspace | `WINDOWADDRESS` ,`WORKSPACEID`,`WORKSPACENAME` |
2022-10-07 23:24:46 +02:00
| openlayer | emitted when a layerSurface is mapped | `NAMESPACE` |
| closelayer | emitted when a layerSurface is unmapped | `NAMESPACE` |
2022-09-05 13:51:44 +02:00
| submap | emitted when a keybind submap changes. Empty means default. |`SUBMAPNAME` |
2022-12-09 19:52:43 +01:00
| changefloatingmode | emitted when a window changes its floating mode. `FLOATING` is either 0 or 1. | `WINDOWADDRESS` ,`FLOATING` |
2023-01-20 19:10:34 +01:00
| urgent | emitted when a window requests an `urgent` state | `WINDOWADDRESS` |
2023-01-29 17:27:19 +01:00
| minimize | emitted when a window requests a change to its minimized state. `MINIMIZED` is either 0 or 1. | `WINDOWADDRESS,MINIMIZED` |
2023-05-31 19:56:04 +02:00
| screencast | emitted when a screencopy state of a client changes. Keep in mind there might be multiple separate clients. State is 0/1, owner is 0 - monitor share, 1 - window share | `STATE,OWNER` |
2023-06-03 18:00:27 +02:00
| windowtitle | emitted when a window title changes. | `WINDOWADDRESS` |
2023-09-15 13:07:29 +02:00
| ignoregrouplock | emitted when `ignoregrouplock` is toggled. | `0/1` |
| lockgroups | emitted when `lockgroups` is toggled. | `0/1` |
2023-12-28 22:34:59 +01:00
| configreloaded | emitted when the config is done reloading | empty |
2024-03-18 19:12:46 +01:00
| pin | emitted when a window is pinned or unpinned | `WINDOWADDRESS,PINSTATE` |
2022-08-18 17:22:14 +02:00
2024-02-20 21:16:07 +01:00
{{< callout type = warning > }}
A fullscreen event is not guaranteed to fire on/off once in succession. A window
might do for example 3 requests to be fullscreen'd, which would result in 3
fullscreen events.
{{< / callout > }}
2022-08-12 20:46:36 +02:00
2024-02-20 21:16:07 +01:00
## How to use socket2 with bash
2022-08-12 20:46:36 +02:00
example script using socket2 events with bash and `socat` :
2022-08-13 19:06:18 +02:00
```sh
2022-08-12 20:46:36 +02:00
#!/bin/sh
2023-04-23 22:20:55 +02:00
handle() {
case $1 in
monitoradded*) do_something ;;
focusedmon*) do_something_else ;;
esac
2022-08-12 20:46:36 +02:00
}
2023-04-23 22:20:55 +02:00
socat -U - UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done
2022-08-12 20:46:36 +02:00
```