taffybar: refine tray behavior and add SNI menu debug tooling
This commit is contained in:
19
dotfiles/config/taffybar/scripts/taffybar-capture-sni-menu
Executable file
19
dotfiles/config/taffybar/scripts/taffybar-capture-sni-menu
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
match="${1:-}"
|
||||
wait_secs="${TAFFYBAR_DEBUG_WAIT_SECS:-1}"
|
||||
|
||||
"$root/scripts/taffybar-restart" >/dev/null
|
||||
|
||||
if [[ -n "${match}" ]]; then
|
||||
"$root/scripts/taffybar-popup-sni-menu" "$match" 1
|
||||
else
|
||||
"$root/scripts/taffybar-popup-sni-menu" "" 1
|
||||
fi
|
||||
|
||||
sleep "$wait_secs"
|
||||
|
||||
"$root/scripts/taffybar-screenshot-focused-monitor"
|
||||
23
dotfiles/config/taffybar/scripts/taffybar-popup-sni-menu
Executable file
23
dotfiles/config/taffybar/scripts/taffybar-popup-sni-menu
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
match="${1:-}"
|
||||
submenu="${2:-1}" # 1 = also pop up first submenu
|
||||
|
||||
# Put cursor somewhere predictable in case the compositor/theme uses pointer hints.
|
||||
hyprctl dispatch movecursor 10 10 >/dev/null 2>&1 || true
|
||||
|
||||
# Wait for the debug bus name to appear (taffybar startup can take a moment).
|
||||
for _ in $(seq 1 50); do
|
||||
if busctl --user list 2>/dev/null | rg -Fq 'taffybar.debug'; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
if ! busctl --user list 2>/dev/null | rg -Fq 'taffybar.debug'; then
|
||||
echo "taffybar.debug DBus name not present (is taffybar running with withDebugServer?)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
busctl --user call taffybar.debug /taffybar/debug taffybar.debug PopupSniMenu sb "$match" "$submenu" >/dev/null
|
||||
32
dotfiles/config/taffybar/scripts/taffybar-screenshot-focused-monitor
Executable file
32
dotfiles/config/taffybar/scripts/taffybar-screenshot-focused-monitor
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
hyprctl_cmd=(hyprctl)
|
||||
|
||||
# Hyprland can restart and change the instance signature, leaving old shells with
|
||||
# a stale HYPRLAND_INSTANCE_SIGNATURE. Detect the live instance and use it.
|
||||
if ! hyprctl monitors -j >/dev/null 2>&1; then
|
||||
if [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
|
||||
inst="$(hyprctl instances -j | jq -r --arg sock "$WAYLAND_DISPLAY" '.[] | select(.wl_socket == $sock) | .instance' | head -n1)"
|
||||
else
|
||||
inst="$(hyprctl instances -j | jq -r '.[0].instance // empty')"
|
||||
fi
|
||||
|
||||
if [[ -n "${inst:-}" ]]; then
|
||||
hyprctl_cmd=(hyprctl --instance "$inst")
|
||||
fi
|
||||
fi
|
||||
|
||||
monitors="$("${hyprctl_cmd[@]}" monitors -j)"
|
||||
name="$(jq -r '.[] | select(.focused) | .name' <<<"$monitors")"
|
||||
|
||||
if [[ -z "${name:-}" || "${name}" == "null" ]]; then
|
||||
echo "No focused monitor found." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Include nanoseconds so consecutive screenshots don't overwrite each other.
|
||||
out="/tmp/monitor-${name}-$(date +%Y%m%d-%H%M%S-%N).png"
|
||||
grim -o "$name" "$out"
|
||||
echo "$out"
|
||||
|
||||
Reference in New Issue
Block a user