Update generate-waybar-configs.sh

This commit is contained in:
FURK4NGG
2026-01-20 01:38:11 +03:00
committed by GitHub
parent a784bf7d09
commit 239d74dfec
+51 -11
View File
@@ -4,26 +4,66 @@ set -e
WAYBAR_DIR="$HOME/.config/waybar" WAYBAR_DIR="$HOME/.config/waybar"
BASE_CONFIG="$WAYBAR_DIR/config" BASE_CONFIG="$WAYBAR_DIR/config"
if [ ! -f "$BASE_CONFIG" ]; then command -v hyprctl >/dev/null || { echo "[error] hyprctl not found"; exit 1; }
echo "[error] base config not found" command -v jq >/dev/null || { echo "[error] jq not found"; exit 1; }
exit 1
fi
command -v hyprctl >/dev/null || { cd "$WAYBAR_DIR"
echo "[error] hyprctl not found"
exit 1
}
# -----------------------------
# 1) MONITORLER
# -----------------------------
MONITORS=$(hyprctl -j monitors | jq -r '.[].name') MONITORS=$(hyprctl -j monitors | jq -r '.[].name')
[ -z "$MONITORS" ] && {
echo "[info] no monitors found, skipping"
exit 0
}
# -----------------------------
# 2) BASE CONFIG BELLEĞE AL
# (output temizlenmiş halde)
# -----------------------------
BASE_CONTENT=""
strip_output() {
sed \
-e 's/"output"[[:space:]]*:[[:space:]]*\[[^]]*\],[[:space:]]*//' \
-e '1s/^{//' \
"$1"
}
if [ -f "$BASE_CONFIG" ]; then
echo "[info] base config: config"
BASE_CONTENT="$(strip_output "$BASE_CONFIG")"
else
FIRST_MONITOR_CONFIG=$(ls config-* 2>/dev/null | head -n 1 || true)
[ -z "$FIRST_MONITOR_CONFIG" ] && {
echo "[error] no base config found"
exit 1
}
echo "[info] base config: $FIRST_MONITOR_CONFIG"
BASE_CONTENT="$(strip_output "$FIRST_MONITOR_CONFIG")"
fi
# -----------------------------
# 3) TEMİZLİK (MONITOR VARSA)
# -----------------------------
rm -f config
rm -f config-*
# -----------------------------
# 4) YENİ CONFIGLER
# -----------------------------
for MONITOR in $MONITORS; do for MONITOR in $MONITORS; do
TARGET="$WAYBAR_DIR/config-$MONITOR" TARGET="config-$MONITOR"
{ {
echo '{' echo '{'
echo " \"output\": [\"$MONITOR\"]," echo " \"output\": [\"$MONITOR\"],"
sed '1s/^{//' "$BASE_CONFIG" echo "$BASE_CONTENT"
} > "$TARGET" } > "$TARGET"
echo "[ok] generated $TARGET for $MONITOR" echo "[ok] generated $TARGET"
done done