#!/bin/sh
# Hyprland layout indicator for waybar
# Shows current layout with nerd font icons
# Layouts: master -> tab group (monocle) -> scrolling -> floating
# Check if hyprctl is reachable
if ! hyprctl version >/dev/null 2>&1; then
echo '{"text": "", "tooltip": "Hyprland not connected"}'
exit 0
fi
# Get current layout (redirect stderr to suppress connection errors)
LAYOUT=$(hyprctl getoption general:layout -j 2>/dev/null | jq -r '.str // "unknown"')
# Check workspace rules for allfloat
WSRULES=$(hyprctl activeworkspace -j 2>/dev/null | jq -r '.rules // []')
# Determine icon and tooltip
if [ "$LAYOUT" = "master" ] && echo "$WSRULES" | grep -q "allfloat"; then
ICON=""
TOOLTIP="Floating"
elif [ "$LAYOUT" = "scrolling" ]; then
ICON=""
TOOLTIP="Scrolling"
elif [ "$LAYOUT" = "hy3" ]; then
ICON=""
TOOLTIP="Tab Group (Monocle)"
elif [ "$LAYOUT" = "master" ]; then
ICON=""
TOOLTIP="Master"
else
ICON=""
TOOLTIP="$LAYOUT"
fi
echo "{\"text\": \"$ICON\", \"tooltip\": \"$TOOLTIP\"}"