- moonarch-waybar: on merge failure, remove the stale output so waybar falls back to the system config (previously it kept running with stale merged data despite the error notification claiming otherwise). - moonarch-doctor: hoist INSTALLED assignment above both OFFICIAL and AUR blocks so the script survives set -u when only aur.txt is present. - zshrc parse_git_branch: gate on git rev-parse and replace three grep subshells with bash pattern matching, cutting prompt latency from ~5 subprocesses per render to 2 (status + symbolic-ref). - moonarch-batsaver.service: validate the threshold is an integer 1-100 before writing to sysfs, add NoNewPrivileges and protection directives instead of relying on kernel validation alone. - ci/act-runner/Dockerfile: drop the broad "pacman -Sy *" sudoers entry (only -S --needed is required by makepkg), and pin run.sh to act_runner:0.3.1 so it cannot drift ahead of the pinned binary. - .gitea/workflows/update-pkgver.yaml: push via credential.helper=store with a chmod 600 temp file instead of `git -c http.extraHeader=...`, so the token no longer shows up in /proc/PID/cmdline.
62 lines
1.9 KiB
Bash
Executable File
62 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# ABOUTME: Wrapper that merges system waybar config with per-machine userconfig.
|
|
# ABOUTME: Handles array prepend/append that waybar's native include cannot do.
|
|
|
|
SYSTEM_CONFIG="/etc/xdg/waybar/config"
|
|
SYSTEM_STYLE="/etc/xdg/waybar/style.css"
|
|
USER_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/waybar"
|
|
USERCONFIG="$USER_DIR/userconfig"
|
|
OUTPUT="$USER_DIR/config"
|
|
USER_STYLE="$USER_DIR/style.css"
|
|
|
|
merge_config() {
|
|
mkdir -p "$USER_DIR"
|
|
|
|
if ! jq -s '
|
|
.[0] as $sys | .[1] as $user |
|
|
(($user.prepend // {}) | to_entries) as $prepends |
|
|
(($user.append // {}) | to_entries) as $appends |
|
|
$sys |
|
|
reduce $prepends[] as $p (.;
|
|
.[$p.key] = ($p.value + (.[$p.key] // []))
|
|
) |
|
|
reduce $appends[] as $a (.;
|
|
.[$a.key] = ((.[$a.key] // []) + $a.value)
|
|
) |
|
|
($user | del(.prepend) | del(.append)) as $extras |
|
|
. * $extras
|
|
' "$SYSTEM_CONFIG" "$USERCONFIG" > "${OUTPUT}.tmp" 2>&1; then
|
|
local err
|
|
err=$(cat "${OUTPUT}.tmp")
|
|
rm -f "${OUTPUT}.tmp"
|
|
logger -t moonarch-waybar "Config merge failed: $err"
|
|
notify-send -u critical "moonarch-waybar" "Config merge failed — using system config.\n$err"
|
|
return 1
|
|
fi
|
|
|
|
mv "${OUTPUT}.tmp" "$OUTPUT"
|
|
}
|
|
|
|
bootstrap_style() {
|
|
if [[ ! -f "$USER_STYLE" ]]; then
|
|
mkdir -p "$USER_DIR"
|
|
cat > "$USER_STYLE" << 'CSS'
|
|
/* Generated by moonarch-waybar — add custom styles below */
|
|
@import url("/etc/xdg/waybar/style.css");
|
|
CSS
|
|
fi
|
|
}
|
|
|
|
if [[ -f "$USERCONFIG" ]]; then
|
|
if [[ ! -f "$OUTPUT" ]] ||
|
|
[[ "$USERCONFIG" -nt "$OUTPUT" ]] ||
|
|
[[ "$SYSTEM_CONFIG" -nt "$OUTPUT" ]]; then
|
|
# On merge failure the previous $OUTPUT is stale — remove it so waybar
|
|
# falls back to XDG's system config instead of running with stale merged data.
|
|
merge_config || rm -f "$OUTPUT"
|
|
fi
|
|
bootstrap_style
|
|
fi
|
|
|
|
exec waybar "$@"
|