Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

activeworkspace IPC/hyprctl command

Open yavko opened this issue 2 years ago • 3 comments

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!

yavko avatar Jan 28 '23 18:01 yavko

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.

leg7 avatar Jan 28 '23 19:01 leg7

Yeah thats how I have it implemented with Hyprland-rs https://github.com/hyprland-community/hyprland-rs/blob/d1613d7a83fe03dc62dafde1da2b4dfd47796a14/src/data/regular.rs#L178

yavko avatar Jan 28 '23 19:01 yavko

After messing more with jq I found a way faster and better command

hyprctl -j monitors | jq '.[] | select(.focused == true) | .activeWorkspace.id'

leg7 avatar Jan 28 '23 22:01 leg7