I'm working on building a status bar using Eww on Hyprland, and I want to set a different color for the currently active workspace. I've successfully displayed the workspaces with the following command:
(defpoll workspaces :interval "100ms"
`hyprctl workspaces -j`
)
However, I'm having trouble with the active workspace. When I try to set it with:
(defpoll activeworkspace :interval "100ms"
`hyprctl activeworkspace -j`
)
The `activeworkspace` variable ends up empty when I run `eww state`, which causes errors in the logs:
error: Failed to turn `` into a value of type json-value
1 /home/togares/.config/eww/eww.yuck:61:23
61 :class {activeworkspace.id == ws.id ? "active" : "inactive"}
I've tried piping the Hyprctl output through `jq -s` in hopes of formatting it for an array, but nothing seems to work. What am I missing here?
1 Answer
The error you're seeing is likely because the `activeworkspace` variable is trying to pull from an empty string. You might want to check out this GitHub discussion: https://github.com/hyprwm/Hyprland/discussions/860, where a similar issue was addressed. Essentially, using `hyprctl -j monitors` to get the active workspace might be a better approach, especially if you're getting no output from your current command. Since the command you're using doesn't work when the workspace is empty, what you need is to first get the active workspace ID from the monitor information, then proceed from there.
Here's a snippet this user shared that you might find handy:
```bash
CURRENT_DESKTOP=$(echo -e "$(hyprctl -j monitors)" | jq -r '.[0] | "(.activeWorkspace.id)"')
```
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically