Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use json output for more robust parsing #5

Open
kerneis-anssi opened this issue Apr 12, 2023 · 1 comment
Open

Use json output for more robust parsing #5

kerneis-anssi opened this issue Apr 12, 2023 · 1 comment

Comments

@kerneis-anssi
Copy link

Hi,

I just looked at your script here:

hyprctl monitors > $monitors

(referenced from hyprwm/Hyprland#747 (comment))

I'm trying to get xmonad-like workspace behavior so this is exactly what I was looking for, thanks for making it public.

For your information, you could make your parsing more robust by using the json output of hyprctl, combined with jq: https://stedolan.github.io/jq/manual/

For instance, the following will display the id of the currently focused monitor:

hyprctl monitors -j|jq '.[]|select(.focused)|.id'
@taylor85345
Copy link
Owner

taylor85345 commented Apr 18, 2023

I actually rewrote this script using jq a few months back, but jq is seriously slow, especially when running multiple queries back-to-back, which made workspace switching noticeably sluggish. Unless I can find a faster alternative to jq for parsing json, or figure out how to streamline the script to require fewer jq queries (I have some ideas), I will be sticking with the current grep+awk method for the time being and just dealing with the occasional breakage.

Honestly this would probably be better implemented as a plugin, but I don't have the C++ knowledge to make that happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants