I'm trying to create a status bar using EWW on Hyprland, and I want to color the active workspace differently. I have the current workspaces displaying fine with `defpoll`, but when I try the same for the active workspace, the variable isn't setting properly. Here's what I'm using:
```lisp
(defpoll activeworkspace :interval "100ms"
`hyprctl activeworkspace -j`)
```
When I check the state with `eww state`, the `activeworkspace` variable is empty, and I'm getting an error in the logs:
```
error: Failed to turn `` into a value of type json-value
```
I also tried using `jq -s` to process the output, but that didn't work either. Any suggestions on what I might be doing wrong? And by the way, I'm using Arch Linux!
2 Answers
The issue you're running into is because the `activeworkspace` variable is trying to grab an ID from an empty string. Make sure that the command you're using with `defpoll` is set up correctly. There's a discussion on GitHub that might help:
https://github.com/hyprwm/Hyprland/discussions/860
Check out the suggestion about using `hyprctl monitors`, which can give you the active workspace directly. You want something like this to get the ID:
```
#!/bin/sh
CURRENT_DESKTOP=$(echo -e "$(hyprctl -j monitors)" | jq -r '.[0] | "(.activeWorkspace.id)"')
```
This way, you can always ensure you're grabbing the right active workspace ID.
I get why this can be frustrating! But just to clarify, when you run `hyprctl activeworkspace -j` in the terminal, does it return the correct output? If it does, the issue might be in how EWW is polling that output.
I understand if the script seems like overkill for what you're trying to achieve, but it could solve the issue. Besides, maybe simplifying the command or checking for any syntax errors could do the trick!
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