Some checks failed
Build and publish packages / build-and-publish (push) Failing after 9s
Stages defaults/etc/mpv/ to /usr/share/moonarch/mpv/ and copies mpv.conf + modernz.conf into /etc/mpv/ on install. modernz.conf deliberately overwrites the AUR default from mpv-modernz-git. pkgrel bumped to 11.
109 lines
5.0 KiB
Plaintext
109 lines
5.0 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 foot config (file owned by foot package, overwrite deliberately)
|
|
cp /usr/share/moonarch/foot/foot.ini /etc/xdg/foot/foot.ini
|
|
|
|
# Deploy waybar style (file owned by waybar package, overwrite deliberately)
|
|
cp /usr/share/moonarch/waybar/style.css /etc/xdg/waybar/style.css
|
|
|
|
# Deploy swaync config (files owned by swaync package, overwrite deliberately)
|
|
cp /usr/share/moonarch/swaync/config.json /etc/xdg/swaync/config.json
|
|
cp /usr/share/moonarch/swaync/style.css /etc/xdg/swaync/style.css
|
|
|
|
# Deploy mpv configs (modernz.conf owned by mpv-modernz-git, overwrite deliberately)
|
|
install -Dm644 /usr/share/moonarch/mpv/mpv.conf /etc/mpv/mpv.conf
|
|
if [ -d /etc/mpv/script-opts ]; then
|
|
cp /usr/share/moonarch/mpv/modernz.conf /etc/mpv/script-opts/modernz.conf
|
|
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
|
|
|
|
# Clean up legacy paru PKGBUILD-repo config. Moonarch now ships binaries
|
|
# exclusively through the Arch registry (pacman repo in /etc/pacman.conf);
|
|
# the [moonarch-pkgbuilds] section and Mode = arp are obsolete.
|
|
PARU_CONF="/etc/paru.conf"
|
|
if [ -f "$PARU_CONF" ]; then
|
|
sed -i '/^Mode[[:space:]]*=[[:space:]]*arp\s*$/d' "$PARU_CONF"
|
|
sed -i '/^\[moonarch-pkgbuilds\]$/,/^$/d' "$PARU_CONF"
|
|
fi
|
|
|
|
# Cleanup legacy user-level configs (moved to system-level)
|
|
while IFS=: read -r _ _ uid _ _ home _; do
|
|
if [ "$uid" -ge 1000 ] && [ "$uid" -lt 60000 ] && [ -d "$home" ]; then
|
|
rm -f "$home/.config/paru/paru.conf" 2>/dev/null || true
|
|
rmdir "$home/.config/paru" 2>/dev/null || true
|
|
for svc in cliphist kanshi nautilus walker; do
|
|
rm -f "$home/.config/systemd/user/${svc}.service" 2>/dev/null || true
|
|
rm -f "$home/.config/systemd/user/graphical-session.target.wants/${svc}.service" 2>/dev/null || true
|
|
done
|
|
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
|
|
|
|
# Battery conservation mode: create state directory and enable restore service
|
|
install -dm775 -g wheel /var/lib/moonarch
|
|
if [ -f /sys/class/power_supply/BAT0/charge_control_end_threshold ]; then
|
|
systemctl enable moonarch-batsaver.service 2>/dev/null || true
|
|
fi
|
|
|
|
echo "==> Moonarch defaults installed."
|
|
echo "==> For first-time setup run: /opt/moonarch/scripts/post-install.sh"
|
|
echo "==> This enables services and configures firewall."
|
|
}
|
|
|
|
pre_upgrade() {
|
|
# Remove untracked walker theme files from pre-package manual deploys.
|
|
# Without this, pacman refuses to overwrite files it doesn't own.
|
|
if [ -d /etc/xdg/walker/themes/moonarch ] && ! pacman -Qo /etc/xdg/walker/themes/moonarch/style.css &>/dev/null; then
|
|
rm -rf /etc/xdg/walker/themes/moonarch
|
|
fi
|
|
|
|
# Migrate cliphist.service → cliphist-text + cliphist-image
|
|
if [ -f /etc/systemd/user/cliphist.service ]; then
|
|
while IFS=: read -r _ _ uid _ _ home _; do
|
|
if [ "$uid" -ge 1000 ] && [ "$uid" -lt 60000 ] && [ -d "$home" ]; then
|
|
rm -f "$home/.config/systemd/user/graphical-session.target.wants/cliphist.service" 2>/dev/null || true
|
|
fi
|
|
done < /etc/passwd
|
|
rm -f /etc/systemd/user/graphical-session.target.wants/cliphist.service 2>/dev/null || true
|
|
fi
|
|
}
|
|
|
|
post_upgrade() {
|
|
post_install
|
|
}
|