eww replacement of waybar

This commit is contained in:
samantha42
2026-04-20 20:37:54 +02:00
parent a240874719
commit 52fa42698f
14 changed files with 591 additions and 119 deletions

View File

@@ -0,0 +1,24 @@
#!/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

View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Outputs one of:
# offline
# wifi:<signal>%
# eth:<ip>
# Check ethernet first
ETH=$(ip -o link show | awk '$9=="UP" && $2!="lo:" {print $2}' | grep -v "^wl" | head -1 | tr -d ':')
if [[ -n "$ETH" ]]; then
IP=$(ip -4 addr show "$ETH" 2>/dev/null | awk '/inet /{print $2}' | cut -d/ -f1 | head -1)
if [[ -n "$IP" ]]; then
echo "eth:${IP}"
exit 0
fi
fi
# Check wifi
WIFI=$(ip -o link show | awk '$9=="UP" && $2~/^wl/ {print $2}' | tr -d ':' | head -1)
if [[ -n "$WIFI" ]]; then
SIGNAL=$(awk "/${WIFI}/{print int(\$3*100/70)}" /proc/net/wireless 2>/dev/null | head -1)
[[ -z "$SIGNAL" ]] && SIGNAL="?"
echo "wifi:${SIGNAL}%"
exit 0
fi
echo "offline"

14
eww/scripts/get-theme.sh Normal file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Wraps your existing theme-cycle.sh to extract a display icon for eww.
# theme-cycle.sh status returns JSON like: {"text":"...","class":"...","tooltip":"..."}
# We parse the "text" field and emit it directly.
RAW=$(bash "$HOME/.config/hypr/theme-cycle.sh" status 2>/dev/null)
# If it's JSON, extract text field
if echo "$RAW" | jq -e . >/dev/null 2>&1; then
echo "$RAW" | jq -r '.text // "󰔎"'
else
# Plain text fallback
echo "${RAW:-󰔎}"
fi

21
eww/scripts/get-volume.sh Normal file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Outputs either:
# muted
# <0-100> (integer volume)
SINK=$(pactl get-default-sink 2>/dev/null)
if [[ -z "$SINK" ]]; then
echo "muted"
exit 0
fi
INFO=$(pactl get-sink-volume "$SINK" 2>/dev/null)
MUTED=$(pactl get-sink-mute "$SINK" 2>/dev/null | awk '{print $2}')
if [[ "$MUTED" == "yes" ]]; then
echo "muted"
exit 0
fi
VOL=$(echo "$INFO" | grep -oP '\d+(?=%)' | head -1)
echo "${VOL:-0}"

38
eww/scripts/get-workspaces.sh Executable file
View 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

21
eww/scripts/launch.sh Normal file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
EWW="eww -c $HOME/.config/eww"
$EWW kill 2>/dev/null
sleep 0.5
declare -A BAR_MAP=(
["DP-2"]="bar-dp2"
["HDMI-A-1"]="bar-hdmi"
)
while IFS= read -r line; do
id=$(echo "$line" | awk '{print $1}')
name=$(echo "$line" | awk '{print $2}')
bar_name="${BAR_MAP[$name]}"
if [[ -z "$bar_name" ]]; then
echo "Warning: no bar mapped for monitor '$name'"
continue
fi
echo "Opening $bar_name on $name (index $id)"
$EWW open "$bar_name"
done < <(hyprctl monitors -j | jq -r '.[] | "\(.id) \(.name)"')