moonarch-pkgbuilds/moonarch-git/moonarch.install
nevaforget d827c689b0 Avoid file conflict with walker package for config.toml
walker owns /etc/xdg/walker/config.toml and overwrites it on every
update. Instead of fighting for that path, deploy our config override
to user homes (~/.config/walker/) via the .install hook where XDG
lookup finds it first. Also fix stale rofi dependency → walker + elephant.
2026-03-30 19:40:14 +02:00

48 lines
2.1 KiB
Plaintext

# ABOUTME: Post-install hooks for moonarch-git package.
# ABOUTME: Handles zsh integration and configs owned by other packages.
post_install() {
# Zsh integration: source moonarch defaults for users without ~/.zshrc
if ! grep -q "zshrc.moonarch" /etc/zsh/zshrc 2>/dev/null; then
echo '# Moonarch defaults (overridden by ~/.zshrc)' >> /etc/zsh/zshrc
echo '[[ ! -f "$HOME/.zshrc" ]] && source /etc/zsh/zshrc.moonarch' >> /etc/zsh/zshrc
fi
# Deploy greetd config (file owned by greetd package, overwrite deliberately)
if [ -d /etc/greetd ]; then
cp /usr/share/moonarch/greetd/config.toml /etc/greetd/config.toml
cp /usr/share/moonarch/greetd/niri-greeter.kdl /etc/greetd/niri-greeter.kdl
fi
# Deploy moongreet config (file owned by moongreet-git, overwrite deliberately)
if [ -d /etc/moongreet ]; then
cp /usr/share/moonarch/moongreet/moongreet.toml /etc/moongreet/moongreet.toml
fi
# Deploy Walker config override to skel and existing user homes.
# Only copies if user has no config yet — never overwrites manual edits.
install -Dm644 /usr/share/moonarch/walker-config.toml \
/etc/skel/.config/walker/config.toml
while IFS=: read -r _ _ uid gid _ home _; do
if [ "$uid" -ge 1000 ] && [ "$uid" -lt 60000 ] && [ -d "$home" ]; then
if [ ! -f "$home/.config/walker/config.toml" ]; then
install -Dm644 -o "$uid" -g "$gid" /usr/share/moonarch/walker-config.toml \
"$home/.config/walker/config.toml"
fi
fi
done < /etc/passwd
# Cleanup legacy /usr/local/bin/ scripts from pre-package installs
rm -f /usr/local/bin/moonarch-* 2>/dev/null || true
rm -f /usr/local/bin/swww /usr/local/bin/swww-daemon 2>/dev/null || true
rm -f /usr/local/bin/moonarch-update 2>/dev/null || true
echo "==> Moonarch defaults installed."
echo "==> For first-time setup run: /opt/moonarch/scripts/post-install.sh"
echo "==> This enables services, configures firewall, and sets up user defaults."
}
post_upgrade() {
post_install
}