diff --git a/dotfiles/config/taffybar/scripts/taffybar-restart b/dotfiles/config/taffybar/scripts/taffybar-restart index 1dc5e9d7..d6ba6e7b 100755 --- a/dotfiles/config/taffybar/scripts/taffybar-restart +++ b/dotfiles/config/taffybar/scripts/taffybar-restart @@ -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)" + 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 diff --git a/dotfiles/config/taffybar/scripts/taffybar-run b/dotfiles/config/taffybar/scripts/taffybar-run index b83919ec..138bdb3b 100755 --- a/dotfiles/config/taffybar/scripts/taffybar-run +++ b/dotfiles/config/taffybar/scripts/taffybar-run @@ -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)" + 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 diff --git a/dotfiles/config/taffybar/taffybar b/dotfiles/config/taffybar/taffybar index 658bc71d..d985cabb 160000 --- a/dotfiles/config/taffybar/taffybar +++ b/dotfiles/config/taffybar/taffybar @@ -1 +1 @@ -Subproject commit 658bc71dc750b6a73ff3e86c872cf72093815c58 +Subproject commit d985cabb6ce104c7c74df6da23454cf0a747f3ed diff --git a/dotfiles/config/taffybar/taffybar.css b/dotfiles/config/taffybar/taffybar.css index 6369826e..6f7dc78b 100644 --- a/dotfiles/config/taffybar/taffybar.css +++ b/dotfiles/config/taffybar/taffybar.css @@ -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