Fix taffybar Hyprland launch environment

This commit is contained in:
2026-05-01 22:37:25 -07:00
parent 5637db1182
commit 4cccd9db2d
4 changed files with 34 additions and 17 deletions

View File

@@ -7,20 +7,24 @@ pkill -u "$USER" -x taffybar || true
cd "$root"
# Hyprland can restart and change the instance signature, leaving old shells with
# a stale HYPRLAND_INSTANCE_SIGNATURE. Fix it before launching taffybar so any
# `hyprctl` calls inside the bar work.
# Hyprland can restart and change the instance signature, and controller shells
# can retain stale X11 session variables. Prefer the live Hyprland instance when
# one is available so taffybar starts on the Wayland backend.
if command -v hyprctl >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
if ! hyprctl monitors -j >/dev/null 2>&1; then
instances_json="$(hyprctl instances -j 2>/dev/null || true)"
if [[ -n "${instances_json:-}" ]]; then
if [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
inst="$(printf '%s\n' "$instances_json" | jq -r --arg sock "$WAYLAND_DISPLAY" '.[] | select(.wl_socket == $sock) | .instance' 2>/dev/null | head -n1 || true)"
inst_row="$(printf '%s\n' "$instances_json" | jq -r --arg sock "$WAYLAND_DISPLAY" '.[] | select(.instance and .wl_socket and .wl_socket == $sock) | [.instance, .wl_socket] | @tsv' 2>/dev/null | head -n1 || true)"
else
inst="$(printf '%s\n' "$instances_json" | jq -r '.[0].instance // empty' 2>/dev/null || true)"
inst_row="$(printf '%s\n' "$instances_json" | jq -r '.[] | select(.instance and .wl_socket) | [.instance, .wl_socket] | @tsv' 2>/dev/null | head -n1 || true)"
fi
if [[ -n "${inst:-}" ]]; then
if [[ -n "${inst_row:-}" ]]; then
read -r inst wl_socket <<<"$inst_row"
export HYPRLAND_INSTANCE_SIGNATURE="$inst"
export WAYLAND_DISPLAY="$wl_socket"
export XDG_SESSION_TYPE=wayland
export GDK_BACKEND=wayland
fi
fi
fi

View File

@@ -4,20 +4,24 @@ set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$root"
# Hyprland can restart and change the instance signature, leaving old shells with
# a stale HYPRLAND_INSTANCE_SIGNATURE. Fix it before launching taffybar so any
# `hyprctl` calls inside the bar work.
# Hyprland can restart and change the instance signature, and controller shells
# can retain stale X11 session variables. Prefer the live Hyprland instance when
# one is available so taffybar starts on the Wayland backend.
if command -v hyprctl >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
if ! hyprctl monitors -j >/dev/null 2>&1; then
instances_json="$(hyprctl instances -j 2>/dev/null || true)"
if [[ -n "${instances_json:-}" ]]; then
if [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
inst="$(printf '%s\n' "$instances_json" | jq -r --arg sock "$WAYLAND_DISPLAY" '.[] | select(.wl_socket == $sock) | .instance' 2>/dev/null | head -n1 || true)"
inst_row="$(printf '%s\n' "$instances_json" | jq -r --arg sock "$WAYLAND_DISPLAY" '.[] | select(.instance and .wl_socket and .wl_socket == $sock) | [.instance, .wl_socket] | @tsv' 2>/dev/null | head -n1 || true)"
else
inst="$(printf '%s\n' "$instances_json" | jq -r '.[0].instance // empty' 2>/dev/null || true)"
inst_row="$(printf '%s\n' "$instances_json" | jq -r '.[] | select(.instance and .wl_socket) | [.instance, .wl_socket] | @tsv' 2>/dev/null | head -n1 || true)"
fi
if [[ -n "${inst:-}" ]]; then
if [[ -n "${inst_row:-}" ]]; then
read -r inst wl_socket <<<"$inst_row"
export HYPRLAND_INSTANCE_SIGNATURE="$inst"
export WAYLAND_DISPLAY="$wl_socket"
export XDG_SESSION_TYPE=wayland
export GDK_BACKEND=wayland
fi
fi
fi

View File

@@ -129,6 +129,15 @@
padding: 0px;
}
/* This must outrank the end-widget nth-last-child color rotation. Otherwise
the collapsed MPRIS end widget can still render as a thin blue strip. */
.taffy-box > .outer-pad.end-widget.mpris.no-visible-children {
background-color: @transparent;
background-image: none;
box-shadow: none;
border-width: 0px;
}
/* Workspaces styling */
/* Reset workspace .outer-pad pills to default styling so the nth-child color