eww replacement of waybar
This commit is contained in:
38
eww/scripts/get-workspaces.sh
Executable file
38
eww/scripts/get-workspaces.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
OUTPUT="${1:-DP-2}"
|
||||
|
||||
if [[ "$OUTPUT" == "DP-2" ]]; then
|
||||
IDS=(1 2 3 4 5)
|
||||
else
|
||||
IDS=(6 7 8 9 10)
|
||||
fi
|
||||
|
||||
emit() {
|
||||
local active urgent result
|
||||
|
||||
active=$(hyprctl activeworkspace -j 2>/dev/null | jq -r '.id')
|
||||
urgent=$(hyprctl clients -j 2>/dev/null \
|
||||
| jq -r '[.[] | select(.urgent==true) | .workspace.id] | unique | .[]')
|
||||
|
||||
result="["
|
||||
for id in "${IDS[@]}"; do
|
||||
local is_active="false"
|
||||
local is_urgent="false"
|
||||
[[ "$id" == "$active" ]] && is_active="true"
|
||||
grep -qx "$id" <<< "$urgent" && is_urgent="true"
|
||||
result+="{\"id\":$id,\"label\":\"$id\",\"active\":$is_active,\"urgent\":$is_urgent,\"output\":\"$OUTPUT\"},"
|
||||
done
|
||||
|
||||
printf '%s\n' "${result%,}]"
|
||||
}
|
||||
|
||||
# emit once on start
|
||||
emit
|
||||
|
||||
# listen for events and re-emit
|
||||
socat -u "UNIX-CONNECT:/tmp/hypr/${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock" - \
|
||||
| stdbuf -oL grep -E "^(workspace|focusedmon|activewindow|urgent|createworkspace|destroyworkspace)>" \
|
||||
| while IFS= read -r _; do
|
||||
sleep 0.05
|
||||
emit
|
||||
done
|
||||
Reference in New Issue
Block a user