diff --git a/bin/omarchy-dev-link b/bin/omarchy-dev-link new file mode 100755 index 00000000..4048ba2a --- /dev/null +++ b/bin/omarchy-dev-link @@ -0,0 +1,67 @@ +#!/bin/bash + +# omarchy:summary=Point Omarchy at a local checkout for live editing +# omarchy:group=dev +# omarchy:args= +# omarchy:examples=omarchy dev link ~/Work/omarchy/omarchy-installer + +set -euo pipefail + +if [[ $# -ne 1 || $1 == "-h" || $1 == "--help" ]]; then + cat < + +Writes /etc/omarchy.conf so OMARCHY_PATH resolves to +in all new shells, the Hyprland session, and Quickshell. Restarts +omarchy-shell and reloads hyprctl so changes take effect immediately. + +Affects only \$OMARCHY_PATH-resolved trees: bin/, default/, shell/, +themes/, applications/, config/. Files installed at fixed system paths +(/etc/, /usr/lib/systemd/, udev rule bodies, /etc/skel after user +creation, /usr/share/plymouth) are NOT covered — for those, use +omarchy-dev-pkg-test to build and install the package from the checkout. +USAGE + exit 0 +fi + +target=$(realpath -e "$1" 2>/dev/null) || { + echo "Error: path does not exist: $1" >&2 + exit 1 +} + +# Sanity: looks like an omarchy-installer checkout? +for required in bin default shell; do + if [[ ! -d "$target/$required" ]]; then + echo "Warning: $target/$required not found — does this look like an omarchy-installer checkout?" >&2 + fi +done + +echo "Pointing Omarchy at $target" +printf 'export OMARCHY_PATH="${OMARCHY_PATH:-%s}"\n' "$target" | sudo tee /etc/omarchy.conf >/dev/null + +# Update the current shell so the rest of this script and anything spawned +# from it see the new path. +export OMARCHY_PATH="$target" +export PATH="$target/bin:$PATH" + +# Update the live Hyprland session if one is running. +if command -v hyprctl >/dev/null 2>&1 && hyprctl version &>/dev/null; then + hyprctl setenv OMARCHY_PATH "$target" >/dev/null + hyprctl setenv PATH "$PATH" >/dev/null + echo " Updated Hyprland session env." + + systemctl --user import-environment OMARCHY_PATH PATH 2>/dev/null || true + echo " Updated systemd --user env." + + if pgrep -x quickshell >/dev/null 2>&1; then + omarchy-restart-shell + echo " Restarted omarchy-shell." + fi + + hyprctl reload >/dev/null + echo " Reloaded Hyprland config." +fi + +echo +echo "Done. Open a new shell (or restart existing ones) to pick up the new" +echo "OMARCHY_PATH. Run 'omarchy dev unlink' to restore the package install." diff --git a/bin/omarchy-dev-pkg-test b/bin/omarchy-dev-pkg-test new file mode 100755 index 00000000..d835e167 --- /dev/null +++ b/bin/omarchy-dev-pkg-test @@ -0,0 +1,66 @@ +#!/bin/bash + +# omarchy:summary=Build and install an Omarchy package from a local checkout +# omarchy:group=dev +# omarchy:args=[package-name] [path-to-checkout] +# omarchy:examples=omarchy dev pkg-test omarchy-settings | omarchy dev pkg-test omarchy ~/Work/omarchy/omarchy-installer + +set -euo pipefail + +if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then + cat <[.dirty]' so +'pacman -Q' makes it obvious where the installed version came from. + +PKGBUILDs are read from \${OMARCHY_PKGBUILDS_DIR:-~/Work/omarchy/omarchy-pkgs/pkgbuilds}//. +USAGE + exit 0 +fi + +PKG="${1:-omarchy-settings}" +CHECKOUT="${2:-$HOME/Work/omarchy/omarchy-installer}" +PKGBUILDS_ROOT="${OMARCHY_PKGBUILDS_DIR:-$HOME/Work/omarchy/omarchy-pkgs/pkgbuilds}" +PKGBUILD_DIR="$PKGBUILDS_ROOT/$PKG" + +if [[ ! -d "$CHECKOUT" ]]; then + echo "Error: checkout not found at $CHECKOUT" >&2 + exit 1 +fi +if [[ ! -f "$PKGBUILD_DIR/PKGBUILD" ]]; then + echo "Error: PKGBUILD not found at $PKGBUILD_DIR/PKGBUILD" >&2 + echo " Pass a different package name as arg 1, or set OMARCHY_PKGBUILDS_DIR." >&2 + exit 1 +fi + +build_dir=$(mktemp -d -t omarchy-dev-pkg-test.XXXXXX) +trap 'rm -rf "$build_dir"' EXIT + +cp -a "$PKGBUILD_DIR/." "$build_dir/" + +# Mark the build with a versioned dev pkgver so pacman -Q makes the source obvious. +short_sha=$(git -C "$CHECKOUT" rev-parse --short HEAD 2>/dev/null || echo "local") +dirty="" +if [[ -d "$CHECKOUT/.git" ]] && [[ -n "$(git -C "$CHECKOUT" status --porcelain)" ]]; then + dirty=".dirty" +fi +new_pkgver="dev.${short_sha}${dirty}" +sed -i "s/^pkgver=.*/pkgver=${new_pkgver}/" "$build_dir/PKGBUILD" + +echo "Building $PKG ${new_pkgver} from $CHECKOUT" +echo " build dir: $build_dir" +echo " PKGBUILD : $PKGBUILD_DIR/PKGBUILD" +echo + +cd "$build_dir" +OMARCHY_SRC="$CHECKOUT" makepkg -si --skipchecksums --noconfirm "${@:3}" diff --git a/bin/omarchy-dev-status b/bin/omarchy-dev-status new file mode 100755 index 00000000..79f7c24c --- /dev/null +++ b/bin/omarchy-dev-status @@ -0,0 +1,34 @@ +#!/bin/bash + +# omarchy:summary=Show the current Omarchy dev-link state +# omarchy:group=dev + +if [[ -f /etc/omarchy.conf ]]; then + # Source in a subshell so we don't mutate the caller's env. + configured=$( + OMARCHY_PATH= + # shellcheck disable=SC1091 + . /etc/omarchy.conf + printf '%s' "${OMARCHY_PATH:-}" + ) + echo "dev-link: ACTIVE" + echo " /etc/omarchy.conf -> OMARCHY_PATH=$configured" +else + configured="/usr/share/omarchy (default)" + echo "dev-link: inactive" +fi + +echo " current shell: OMARCHY_PATH=${OMARCHY_PATH:-}" + +if [[ -f /etc/omarchy.conf && "${OMARCHY_PATH:-}" != "$configured" ]]; then + echo + echo "Note: this shell predates dev-link. Open a new shell to pick up the change," + echo "or 'export OMARCHY_PATH=$configured' to update just this shell." +fi + +if command -v hyprctl >/dev/null 2>&1 && hyprctl version &>/dev/null; then + hypr_path=$(hyprctl getoption -j env 2>/dev/null | sed -n 's/.*OMARCHY_PATH=\([^"]*\).*/\1/p' | head -1) + if [[ -n "$hypr_path" ]]; then + echo " hyprland session: OMARCHY_PATH=$hypr_path" + fi +fi diff --git a/bin/omarchy-dev-unlink b/bin/omarchy-dev-unlink new file mode 100755 index 00000000..dbdd0f52 --- /dev/null +++ b/bin/omarchy-dev-unlink @@ -0,0 +1,52 @@ +#!/bin/bash + +# omarchy:summary=Restore Omarchy to the package install (undo omarchy-dev-link) +# omarchy:group=dev + +set -euo pipefail + +if [[ ${1:-} == "-h" || ${1:-} == "--help" ]]; then + cat </dev/null 2>&1 && hyprctl version &>/dev/null; then + hyprctl setenv OMARCHY_PATH /usr/share/omarchy >/dev/null + hyprctl setenv PATH "$PATH" >/dev/null + echo " Updated Hyprland session env." + + systemctl --user import-environment OMARCHY_PATH PATH 2>/dev/null || true + echo " Updated systemd --user env." + + if pgrep -x quickshell >/dev/null 2>&1; then + omarchy-restart-shell + echo " Restarted omarchy-shell." + fi + + hyprctl reload >/dev/null + echo " Reloaded Hyprland config." +fi + +echo +echo "Done. Existing shells still have the old OMARCHY_PATH until restarted."