2024-02-20 21:16:07 +01:00
|
|
|
---
|
|
|
|
weight: 13
|
|
|
|
title: Expanding functionality
|
|
|
|
---
|
|
|
|
|
2022-08-12 20:46:36 +02:00
|
|
|
Hyprland exposes two powerful sockets for you to use.
|
|
|
|
|
2022-08-13 01:47:48 +02:00
|
|
|
The first, socket1, can be fully controlled with `hyprctl`, see its usage
|
2024-03-17 13:44:39 +01:00
|
|
|
[here](../Using-hyprctl).
|
2022-08-12 20:46:36 +02:00
|
|
|
|
2022-08-13 01:47:48 +02:00
|
|
|
The second, socket2, sends events for certain changes / actions and can be used
|
2024-03-17 13:44:39 +01:00
|
|
|
to react to different events. See its description [here](../../IPC/).
|
2022-08-12 20:46:36 +02:00
|
|
|
|
2024-02-20 21:16:07 +01:00
|
|
|
## Example script
|
2022-08-12 20:46:36 +02:00
|
|
|
|
2022-08-13 01:47:48 +02:00
|
|
|
This bash script will change the outer gaps to 20 if the currently focused
|
|
|
|
monitor is DP-1, and 30 otherwise.
|
2022-08-12 20:46:36 +02:00
|
|
|
|
2023-04-23 22:20:55 +02:00
|
|
|
```bash
|
2024-03-08 00:38:37 +01:00
|
|
|
#!/usr/bin/env bash
|
2022-08-12 20:46:36 +02:00
|
|
|
|
|
|
|
function handle {
|
|
|
|
if [[ ${1:0:10} == "focusedmon" ]]; then
|
|
|
|
if [[ ${1:12:4} == "DP-1" ]]; then
|
|
|
|
hyprctl keyword general:gaps_out 20
|
|
|
|
else
|
|
|
|
hyprctl keyword general:gaps_out 30
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-04-28 23:25:40 +02:00
|
|
|
socat - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do handle "$line"; done
|
2022-08-13 01:47:48 +02:00
|
|
|
```
|