Files
omarchy/config/omarchy/hooks/pre-refresh-pacman.d/add-custom-repo.sample
T

25 lines
965 B
Bash

#!/bin/bash
# This hook is called by `omarchy refresh pacman` AFTER the channel template
# is copied and BEFORE the package transaction runs, so your changes shape
# that transaction. Use it to layer customizations onto the freshly-written
# pacman.conf — common cases are adding a custom repository (e.g. CachyOS,
# Chaotic-AUR, an internal company repo) or extra IgnorePkg lines.
#
# The hook runs as the invoking user after Omarchy invalidates its sudo cache.
# A sudo command here therefore requires its own explicit authorization.
#
# To put it into use, remove .sample from this file name.
# Example: add an Include line above the first repository, [omarchy].
# Maintain the repo entries in /etc/pacman.d/custom-repos.conf yourself.
CONF=/etc/pacman.conf
SNIPPET=/etc/pacman.d/custom-repos.conf
MARKER="Include = $SNIPPET"
[[ -r $SNIPPET ]] || exit 0
grep -qxF "$MARKER" "$CONF" && exit 0
sudo sed -i "0,/^\[omarchy\]/s||$MARKER\n\n[omarchy]|" "$CONF"