From aada2a4c9c365999fb9cb9a27e52aeb8a1467bc5 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Mon, 11 May 2026 20:01:18 -0400 Subject: [PATCH] Preserve waybar position on refresh --- bin/omarchy-refresh-waybar | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/omarchy-refresh-waybar b/bin/omarchy-refresh-waybar index 62aebde4..347a5936 100755 --- a/bin/omarchy-refresh-waybar +++ b/bin/omarchy-refresh-waybar @@ -3,6 +3,17 @@ # omarchy:summary=Reset Waybar config to Omarchy defaults # omarchy:examples=omarchy refresh waybar +WAYBAR_CONFIG="$HOME/.config/waybar/config.jsonc" + +position=$(sed -nE 's/.*"position"[[:space:]]*:[[:space:]]*"(top|bottom|left|right)".*/\1/p' "$WAYBAR_CONFIG" 2>/dev/null | head -n 1) +height=$(sed -nE 's/.*"height"[[:space:]]*:[[:space:]]*([0-9]+).*/\1/p' "$WAYBAR_CONFIG" 2>/dev/null | head -n 1) +width=$(sed -nE 's/.*"width"[[:space:]]*:[[:space:]]*([0-9]+).*/\1/p' "$WAYBAR_CONFIG" 2>/dev/null | head -n 1) + omarchy-refresh-config waybar/config.jsonc omarchy-refresh-config waybar/style.css + +[[ -n $position ]] && sed -i -E "s/(\"position\"[[:space:]]*:[[:space:]]*\")[a-z]+(\")/\\1${position}\\2/" "$WAYBAR_CONFIG" +[[ -n $height ]] && sed -i -E "s/(\"height\"[[:space:]]*:[[:space:]]*)[0-9]+/\\1${height}/" "$WAYBAR_CONFIG" +[[ -n $width ]] && sed -i -E "s/(\"width\"[[:space:]]*:[[:space:]]*)[0-9]+/\\1${width}/" "$WAYBAR_CONFIG" + omarchy-restart-waybar