Hyprland
Hyprland copied to clipboard
activeworkspace IPC/hyprctl command
Yes I know this is quite easy to replicate, but it would be more concise and probably more performant if it was built in to the compositor!
If you are using only 1 monitor.
hyprctl -j monitors | jq .[0].activeWorkspace.id
It would be nice to have this be a hyprctl command because having to call jq multiple times when you have multiple monitors is very heavy. For example this is what it looks like with 2 monitors.
if [ $(hyprctl -j monitors | jq .[0].focused) = "true" ]; then
hyprctl -j monitors | jq .[0].activeWorkspace.id)
else
hyprctl -j monitors | jq .[1].activeWorkspace.id)
fi
The more monitors you have the more you have to pipe into jq and that is painfully resource intensive and slow.
Yeah thats how I have it implemented with Hyprland-rs https://github.com/hyprland-community/hyprland-rs/blob/d1613d7a83fe03dc62dafde1da2b4dfd47796a14/src/data/regular.rs#L178
After messing more with jq I found a way faster and better command
hyprctl -j monitors | jq '.[] | select(.focused == true) | .activeWorkspace.id'