https://github.com/zzampax/hyprland-workspaces-ipc
Implementation of UNIX socket-dependent script to handle Hyprlands workspaces, multi-monitor support [MIRROR]
https://github.com/zzampax/hyprland-workspaces-ipc
hyprland hyprland-ipc rust unix-socket unix-socket-ipc
Last synced: 4 months ago
JSON representation
Implementation of UNIX socket-dependent script to handle Hyprlands workspaces, multi-monitor support [MIRROR]
- Host: GitHub
- URL: https://github.com/zzampax/hyprland-workspaces-ipc
- Owner: zzampax
- License: agpl-3.0
- Created: 2025-01-13T15:08:07.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-01-13T16:21:51.000Z (5 months ago)
- Last Synced: 2025-01-13T17:28:27.961Z (5 months ago)
- Topics: hyprland, hyprland-ipc, rust, unix-socket, unix-socket-ipc
- Language: Rust
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hyprland Workspaces IPC Script
## Introduction
Real time utility that tracks every workspace currently in use in [Hyprland](https://github.com/hyprwm/Hyprland) filtered by monitor output, example:
```json
{
"workspaces": {
"HDMI-3": [
2,
],
"DP-1": [
1,
],
},
"focused": [
"DP-1",
1,
],
"socket_path": "[...]/.socket2.sock",
}
```
The script relies on `tokio` for handling asynchronous calls to the **UNIX** socket provided by Hyprland and `serde_json` for handling **JSON** encoded output from `hyprctl`.
## How it Works
On execution, the script fetches the current workspaces (filtered by monitor) as long with the focused monitor+workspace pair with the `hyprctl commands`:
```bash
# For workspace list
hyprctl workspaces -j # -j arg for JSON output
# For currently focused workspace
hyprctl activeworkspace -j
```
Adapted for script execution in Rust (using `std::process::{Command, Output}` structs):
```rust
// For workspace list
let output: Output = Command::new("hyprctl")
.arg("workspaces")
.arg("-j")
.output()
.expect("Failed to execute command");
// Same concept for currently focused workspace
// ...
```
The script then proceeds to listen for event calls on the UNIX socket such as:
- `createworkspace`
- `workspace`
- `destroyworkspace`
- `focusedmon`> Keep in mind than no `v2` is considered
## Why?
This project aims to provide a lightweight solution to handle live workspaces information for a taskbar (Wayland, Hyprland).
## License
[GNU Affero General Public License v3.0](LICENSE)