I'm trying to create a status bar using EWW on Hyprland, and my goal is to color the currently active workspace differently. I've set up a polling function to retrieve the workspaces with `defpoll`, and that works perfectly:
(defpoll workspaces :interval "100ms"
`hyprctl workspaces -j`
)
However, when I try to do the same for the active workspace, the variable doesn't get set right, and it's coming up empty:
(defpoll activeworkspace :interval "100ms"
`hyprctl activeworkspace -j`
)
When I check with `eww state`, `activeworkspace` is showing as empty, which triggers an error in the logs:
error: Failed to turn `` into a value of type json-value
/home/togares/.config/eww/eww.yuck:61:23
61
:class {activeworkspace.id == ws.id ? "active" : "inactive"}
I've also tried piping the output of the hyprctl command to `jq -s` to format it into an array like the workspaces, but that didn't help either. What am I missing? Any advice would be appreciated!
1 Answer
The issue you're facing likely stems from trying to get the workspace ID from an empty string. You can check out this discussion on GitHub that might help you out:
https://github.com/hyprwm/Hyprland/discussions/860
A user mentioned that while `hyprctl -j activewindow` could be problematic if the workspace is empty, you can get the active workspace by running `hyprctl -j monitors` instead. Here’s a script that shows how to process output with jq to get the active workspace ID:
```
#!/bin/sh
CURRENT_DESKTOP=$(echo -e "$(hyprctl -j monitors)" | jq -r '.[0] | "(.activeWorkspace.id)"')
//...other commands...
```
This should give you the output you need to work with in your EWW configuration!
Thanks for the info! I ran `hyprctl activeworkspace -j` in the terminal, and it returns valid output, so I'm not sure why it's empty in EWW. Your script looks a bit complex for what I need. I hope I can find a simpler solution!