43 lines
1.1 KiB
Bash
Executable File
43 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
WIN_CLASS="nvim_notes"
|
|
#ICON=" "
|
|
ICON=" "
|
|
|
|
# найти node id
|
|
find_node() {
|
|
for id in $(bspc query -N -n .window 2>/dev/null); do
|
|
if xprop -id "$id" WM_CLASS 2>/dev/null | grep -q "$WIN_CLASS"; then
|
|
echo "$id" && return 0
|
|
fi
|
|
done
|
|
return 1
|
|
}
|
|
|
|
NODE=$(find_node) || NODE=""
|
|
|
|
if [ -z "$NODE" ]; then
|
|
echo "$ICON"
|
|
exit 0
|
|
fi
|
|
|
|
# проверить флаг hidden через JSON (надежно)
|
|
if bspc query -T -n "$NODE" 2>/dev/null | grep -q '"hidden":[[:space:]]*true'; then
|
|
echo "%{T1}$ICON%{T-}%{T2}Скрыто%{T-} "
|
|
exit 0
|
|
fi
|
|
|
|
# если в фокусе — видно
|
|
FOC=$(bspc query -N -n focused.window 2>/dev/null || echo "")
|
|
if [ "$NODE" = "$FOC" ]; then
|
|
echo "%{T1}$ICON%{T-}%{T2}Фокус%{T-} "
|
|
exit 0
|
|
fi
|
|
|
|
# получить список окон текущего десктопа и проверить наличие
|
|
CUR_DESK_WINDOWS=$(bspc query -N -n .window.local 2>/dev/null || bspc query -N -n .window 2>/dev/null)
|
|
if echo "$CUR_DESK_WINDOWS" | grep -qx "$NODE"; then
|
|
echo "%{T1}$ICON%{T-}%{T2}ON%{T-} "
|
|
else
|
|
echo "%{T1}$ICON%{T-}%{T2}ON%{T-} "
|
|
fi
|