Files
dotfiles/eww/scripts/get-active-workspace.sh
2026-04-20 20:37:54 +02:00

24 lines
599 B
Bash

#!/usr/bin/env bash
OUTPUT="${1:-DP-2}"
emit() {
local monitor title
monitor=$(hyprctl monitors -j 2>/dev/null \
| jq -r ".[] | select(.name==\"$OUTPUT\") | .activeWorkspace.id")
title=$(hyprctl clients -j 2>/dev/null \
| jq -r ".[] | select(.workspace.id==$monitor and .focusHistoryID==0) | .title" \
| head -n1)
printf '%s\n' "${title:-}"
}
emit
socat -u "UNIX-CONNECT:/tmp/hypr/${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock" - \
| stdbuf -oL grep -E "^(activewindow|focusedmon|workspace|closewindow)>" \
| while IFS= read -r _; do
sleep 0.05
emit
done