From b633b6e6964a0d0a60ed991805745bd66f280235 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 7 Feb 2026 16:02:55 -0800 Subject: [PATCH] taffybar: add taffybar-crop-bar utility Shell script that crops the top bar region from a screenshot using ffmpeg, auto-detecting height from Hyprland's reserved area. Co-Authored-By: Claude Opus 4.6 --- .../config/taffybar/scripts/taffybar-crop-bar | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 dotfiles/config/taffybar/scripts/taffybar-crop-bar diff --git a/dotfiles/config/taffybar/scripts/taffybar-crop-bar b/dotfiles/config/taffybar/scripts/taffybar-crop-bar new file mode 100755 index 00000000..6e0f7d59 --- /dev/null +++ b/dotfiles/config/taffybar/scripts/taffybar-crop-bar @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +in="${1:?usage: taffybar-crop-bar INPUT_IMAGE [OUTPUT_IMAGE]}" +out="${2:-/tmp/taffybar-crop-$(date +%Y%m%d-%H%M%S-%N).png}" + +# Prefer Hyprland's reserved-top height if available; otherwise fall back to 56px. +h="${BAR_HEIGHT:-}" +if [[ -z "${h}" ]] && command -v hyprctl >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then + # Best-effort: use the focused monitor's reserved top. If hyprctl fails (stale + # instance signature, non-hypr session), we just fall back. + if hyprctl monitors -j >/dev/null 2>&1; then + h="$(hyprctl monitors -j | jq -r '.[] | select(.focused) | .reserved[1]' 2>/dev/null || true)" + fi +fi + +if [[ -z "${h}" || "${h}" == "0" ]]; then + h="56" +fi + +ffmpeg -hide_banner -loglevel error -y \ + -i "$in" \ + -vf "crop=in_w:${h}:0:0" \ + "$out" + +echo "$out" +