Files
moonarch-pkgbuilds/moonarch-git/moonarch.install
T
nevaforget 53f94e548f
Build and publish packages / build-and-publish (push) Successful in 14s
fix(moonarch-git): own /etc/swaylock/config, install blurred wallpaper
swaylock never reads /etc/xdg/, so the config is installed explicitly to
/etc/swaylock/config — its SYSCONFDIR path — instead of going through the
generic defaults/xdg/ sweep. The home seeding drops out; pre_upgrade
retires the pristine copies it left behind (cmp against the still-old
/etc/xdg file, so an edited copy survives) and clears a manually deployed
/etc/swaylock/config that pacman would refuse to overwrite.

wallpaper-blur.jpg ships next to the plain wallpaper as the lock screen
background.
2026-08-18 17:37:55 +02:00

157 lines
7.6 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 and regreet config (config.toml owned by greetd,
# regreet.toml owned by greetd-regreet, 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
cp /usr/share/moonarch/greetd/regreet.toml /etc/greetd/regreet.toml
cp /usr/share/moonarch/greetd/regreet.css /etc/greetd/regreet.css
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
# swaylock needs no home seeding: the config is owned at /etc/swaylock/config,
# which is swaylock's own SYSCONFDIR path, so the package makes it effective
# on its own. See pre_upgrade for the retirement of the former home copies.
# 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
# Cameras off after every boot — only on machines that have one
if ls /sys/class/video4linux/video* >/dev/null 2>&1; then
systemctl enable moonarch-camera.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
# Remove a manually deployed /etc/swaylock/config. The package owns that path
# now; pacman refuses to overwrite a file it does not own. Same reason as the
# walker theme cleanup above.
if [ -f /etc/swaylock/config ] && ! pacman -Qo /etc/swaylock/config &>/dev/null; then
rm -f /etc/swaylock/config
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
# Drop legacy global-scope wlsunset enablement. Nightlight is a toggle —
# the global symlink overrode user-scope disable, so the filter survived
# reboots even after the user turned it off.
rm -f /etc/systemd/user/graphical-session.target.wants/wlsunset.service 2>/dev/null || true
# Point already-seeded stasis configs at swaylock. stasis.rune is copied
# into the user home once and never overwritten, so without this the lock
# and lid actions of an existing install keep calling moonlock.
while IFS=: read -r _ _ uid _ _ home _; do
if [ "$uid" -ge 1000 ] && [ "$uid" -lt 60000 ] && [ -f "$home/.config/stasis/stasis.rune" ]; then
sed -i -e 's/"moonlock"/"swaylock -f"/g' \
-e 's/Niri + moonlock/Niri + swaylock/' \
"$home/.config/stasis/stasis.rune"
fi
done < /etc/passwd
# moongreet.toml.bak predates the package and is owned by nothing. The
# rest of /etc/moongreet/ goes with `pacman -Rns moongreet`.
rm -f /etc/moongreet/moongreet.toml.bak 2>/dev/null || true
# Retire the seeded swaylock home copies. The config now ships to
# /etc/swaylock/config, but the home paths are searched first, so a leftover
# seed copy would shadow it forever — including the blurred wallpaper.
# Only untouched copies go: pre_upgrade still sees the old /etc/xdg file, so
# `cmp` distinguishes a pristine seed from one the user edited. An edited
# copy stays and keeps winning, which is what a user config is for.
if [ -f /etc/xdg/swaylock/config ]; then
if cmp -s /etc/skel/.config/swaylock/config /etc/xdg/swaylock/config; then
rm -f /etc/skel/.config/swaylock/config
rmdir /etc/skel/.config/swaylock 2>/dev/null || true
fi
while IFS=: read -r _ _ uid _ _ home _; do
if [ "$uid" -ge 1000 ] && [ "$uid" -lt 60000 ] \
&& cmp -s "$home/.config/swaylock/config" /etc/xdg/swaylock/config; then
rm -f "$home/.config/swaylock/config"
rmdir "$home/.config/swaylock" 2>/dev/null || true
fi
done < /etc/passwd
fi
}
post_upgrade() {
post_install
}