Turn pkg and cmd functions into bins to avoid PATH issues in subshells

This commit is contained in:
David Heinemeier Hansson
2025-08-31 09:18:06 +02:00
parent 94ad5d4d37
commit 9e5b4fc871
44 changed files with 98 additions and 106 deletions

9
bin/omarchy-cmd-missing Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
for cmd in "$@"; do
if ! command -v "$cmd" &>/dev/null; then
return 0
fi
done
return 1

7
bin/omarchy-cmd-present Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
for cmd in "$@"; do
command -v "$cmd" &>/dev/null || return 1
done
return 0

View File

@@ -14,7 +14,7 @@ for file in ~/.local/share/omarchy/migrations/*.sh; do
if [[ ! -f "$STATE_DIR/$filename" && ! -f "$STATE_DIR/skipped/$filename" ]]; then
echo -e "\e[32m\nRunning migration (${filename%.sh})\e[0m"
if bash -e $file; then
if bash $file; then
touch "$STATE_DIR/$filename"
else
if gum confirm "Migration ${filename%.sh} failed. Skip and continue?"; then

7
bin/omarchy-pkg-add Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
for pkg in "$@"; do
pacman -Q "$pkg" &>/dev/null || return 1
done
return 0

7
bin/omarchy-pkg-drop Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
for pkg in "$@"; do
if pacman -Q "$pkg" &>/dev/null; then
sudo pacman -Rns --noconfirm "$pkg"
fi
done

9
bin/omarchy-pkg-missing Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
for pkg in "$@"; do
if ! pacman -Q "$pkg" &>/dev/null; then
return 0
fi
done
return 1

7
bin/omarchy-pkg-present Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
for pkg in "$@"; do
pacman -Q "$pkg" &>/dev/null || return 1
done
return 0

View File

@@ -65,54 +65,3 @@ img2png() {
-define png:exclude-chunk=all \
"${1%.*}.png"
}
pkg-present() {
for pkg in "$@"; do
pacman -Q "$pkg" &>/dev/null || return 1
done
return 0
}
pkg-missing() {
for pkg in "$@"; do
if ! pacman -Q "$pkg" &>/dev/null; then
return 0
fi
done
return 1
}
pkg-add() {
for pkg in "$@"; do
if ! pacman -Q "$pkg" &>/dev/null; then
sudo pacman -S --noconfirm --needed "$pkg"
fi
done
}
pkg-remove() {
for pkg in "$@"; do
if pacman -Q "$pkg" &>/dev/null; then
sudo pacman -Rns --noconfirm "$pkg"
fi
done
}
cmd-present() {
for cmd in "$@"; do
command -v "$cmd" &>/dev/null || return 1
done
return 0
}
cmd-missing() {
for cmd in "$@"; do
if ! command -v "$cmd" &>/dev/null; then
return 0
fi
done
return 1
}

View File

@@ -1,3 +0,0 @@
echo "Ensure new pkg/cmd functions are available to old-run migrations"
source $OMARCHY_PATH/default/bash/functions

View File

@@ -1,3 +1,3 @@
echo "Add missing installation of bat (used by the ff alias)"
pkg-add bat
omarchy-pkg-add bat

View File

@@ -1,3 +1,3 @@
echo "Installing missing fd terminal tool for finding files"
pkg-add fd
omarchy-pkg-add fd

View File

@@ -1,9 +1,9 @@
echo "Switching from vlc to mpv for the default video player"
if cmd-missing mpv; then
pkg-remove vlc
if omarchy-cmd-missing mpv; then
omarchy-pkg-drop vlc
rm ~/.local/share/applications/vlc.desktop
pkg-add mpv
omarchy-pkg-add mpv
xdg-mime default mpv.desktop video/mp4
xdg-mime default mpv.desktop video/x-msvideo
xdg-mime default mpv.desktop video/x-matroska

View File

@@ -1,3 +1,3 @@
echo "Add LocalSend as new default application"
pkg-add localsend
omarchy-pkg-add localsend

View File

@@ -1,3 +1,3 @@
echo "Install ffmpegthumbnailer for video thumbnails in the file manager"
pkg-add ffmpegthumbnailer
omarchy-pkg-add ffmpegthumbnailer

View File

@@ -1,3 +1,3 @@
echo "Install bash-completion"
pkg-add bash-completion
omarchy-pkg-add bash-completion

View File

@@ -1,6 +1,6 @@
echo "Install Impala as new wifi selection TUI"
if cmd-missing impala; then
pkg-add impala
if omarchy-cmd-missing impala; then
omarchy-pkg-add impala
omarchy-refresh-waybar
fi

View File

@@ -1,3 +1,3 @@
echo "Adding gnome-keyring to make 1password work with 2FA codes"
pkg-add gnome-keyring
omarchy-pkg-add gnome-keyring

View File

@@ -1,4 +1,4 @@
echo "Install Plymouth splash screen"
pkg-add uwsm plymouth
omarchy-pkg-add uwsm plymouth
source "$OMARCHY_PATH/install/login/plymouth.sh"

View File

@@ -1,6 +1,6 @@
echo "Update to use UWSM and seamless login"
if cmd-missing uwsm; then
if omarchy-cmd-missing uwsm; then
sudo rm -f /etc/systemd/system/getty@tty1.service.d/override.conf
sudo rmdir /etc/systemd/system/getty@tty1.service.d/ 2>/dev/null || true

View File

@@ -1,3 +1,3 @@
echo "Install missing docker-buildx package for out-of-the-box Kamal compatibility"
pkg-add docker-buildx
omarchy-pkg-add docker-buildx

View File

@@ -1,3 +1,3 @@
echo "Install slurp + wl-screenrec for new ALT+PrintScreen screen recorder"
pkg-add slurp wl-screenrec
omarchy-pkg-add slurp wl-screenrec

View File

@@ -1,8 +1,8 @@
echo "Replace volume control GUI with a TUI"
if cmd-missing wiremix; then
pkg-add wiremix
pkg-remove pavucontrol
if omarchy-cmd-missing wiremix; then
omarchy-pkg-add wiremix
omarchy-pkg-drop pavucontrol
omarchy-refresh-applications
omarchy-refresh-waybar
fi

View File

@@ -1,3 +1,3 @@
echo "Remove needless fcitx5-configtool package"
pkg-remove fcitx5-configtool
omarchy-pkg-drop fcitx5-configtool

View File

@@ -1,3 +1,3 @@
echo "Install satty for the new screenshot flow"
pkg-add satty
omarchy-pkg-add satty

View File

@@ -1,9 +1,9 @@
echo "Replace wofi with walker as the default launcher"
if cmd-missing walker; then
pkg-add walker-bin libqalculate
if omarchy-cmd-missing walker; then
omarchy-pkg-add walker-bin libqalculate
pkg-remove wofi
omarchy-pkg-drop wofi
rm -rf ~/.config/wofi
mkdir -p ~/.config/walker

View File

@@ -1,6 +1,6 @@
echo "Install swayOSD to show volume status"
if cmd-missing swayosd-server; then
pkg-add swayosd
if omarchy-cmd-missing swayosd-server; then
omarchy-pkg-add swayosd
setsid uwsm app -- swayosd-server &>/dev/null &
fi

View File

@@ -1,3 +1,3 @@
echo "Install wf-recorder for screen recording for nvidia"
pkg-add wf-recorder
omarchy-pkg-add wf-recorder

View File

@@ -1,6 +1,6 @@
echo "Allow updating of timezone by right-clicking on the clock (or running omarchy-cmd-tzupdate)"
if cmd-missing tzupdate; then
if omarchy-cmd-missing tzupdate; then
$OMARCHY_PATH/install/config/timezones.sh
omarchy-refresh-waybar
fi

View File

@@ -1,7 +1,7 @@
echo "Enable auto-discovery of network printers"
if [[ ! -f /etc/systemd/resolved.conf.d/10-disable-multicast.conf ]]; then
pkg-add avahi nss-mdns
omarchy-pkg-add avahi nss-mdns
# Disable multicast dns in resolved. Avahi will provide this for better network printer discovery
sudo mkdir -p /etc/systemd/resolved.conf.d
@@ -10,7 +10,7 @@ if [[ ! -f /etc/systemd/resolved.conf.d/10-disable-multicast.conf ]]; then
fi
if ! grep -q '^CreateRemotePrinters Yes' /etc/cups/cups-browsed.conf; then
pkg-add cups-browsed
omarchy-pkg-add cups-browsed
# Enable automatically adding remote printers
echo 'CreateRemotePrinters Yes' | sudo tee -a /etc/cups/cups-browsed.conf
sudo systemctl enable --now cups-browsed.service

View File

@@ -1,3 +1,3 @@
echo "Add support for accessing Android phone data via file manager"
pkg-add gvfs-mtp
omarchy-pkg-add gvfs-mtp

View File

@@ -1,3 +1,3 @@
echo "Add xmlstarlet needed for updating fonts via Omarchy menu"
pkg-add xmlstarlet
omarchy-pkg-add xmlstarlet

View File

@@ -1,6 +1,6 @@
echo "Configure Docker to use the host's DNS resolver"
if cmd-present docker; then
if omarchy-cmd-present docker; then
# If the daemon configuration has been changed since we wrote it, leave it as-is
ORIGINAL_CONFIG='{"log-driver":"json-file","log-opts":{"max-size":"10m","max-file":"5"}}'

View File

@@ -9,9 +9,9 @@ set_theme_colors() {
fi
}
if cmd-present chromium; then
pkg-remove chromium
pkg-add omarchy-chromium
if omarchy-cmd-present chromium; then
omarchy-pkg-drop chromium
omarchy-pkg-add omarchy-chromium
if pgrep -x chromium; then
if gum confirm "Chromium must be restarted. Ready?"; then

View File

@@ -1,6 +1,6 @@
echo "Add minimal starship prompt to terminal"
if cmd-missing starship; then
pkg-add starship
if omarchy-cmd-missing starship; then
omarchy-pkg-add starship
cp $OMARCHY_PATH/config/starship.toml ~/.config/starship.toml
fi

View File

@@ -1,3 +1,3 @@
echo "Ensure TTE and dependencies are installed"
pkg-add python-poetry-core python-terminaltexteffects
omarchy-pkg-add python-poetry-core python-terminaltexteffects

View File

@@ -1,3 +1,3 @@
echo "Add potentially missing dependency for power profile controls"
pkg-add python-gobject
omarchy-pkg-add python-gobject

View File

@@ -1,3 +1,3 @@
echo "Install wf-recorder for intel based device"
pkg-add wf-recorder
omarchy-pkg-add wf-recorder

View File

@@ -1,4 +1,4 @@
echo "Switch from lazydocker-bin to lazydocker official"
pkg-remove lazydocker-bin
pkg-add lazydocker
omarchy-pkg-drop lazydocker-bin
omarchy-pkg-add lazydocker

View File

@@ -1,13 +1,13 @@
echo "Migrate AUR packages to official repos where possible"
reinstall_package_opr() {
if pkg-present $1; then
if omarchy-pkg-present $1; then
sudo pacman -Rns --noconfirm $1
sudo pacman -S --noconfirm ${2:-$1}
fi
}
pkg-remove yay-bin-debug
omarchy-pkg-drop yay-bin-debug
reinstall_package_opr yay-bin yay
reinstall_package_opr obsidian-bin obsidian

View File

@@ -1,6 +1,6 @@
echo "Replace buggy native Zoom client with webapp"
if pkg-present zoom; then
pkg-remove zoom
if omarchy-pkg-present zoom; then
omarchy-pkg-drop zoom
omarchy-webapp-install "Zoom" https://app.zoom.us/wc/home https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/zoom.png
fi

View File

@@ -1,6 +1,6 @@
echo "Remove any Chaotic-AUR infrastructure packages"
pkg-remove chaotic-keyring chaotic-mirrorlist
omarchy-pkg-drop chaotic-keyring chaotic-mirrorlist
if sudo pacman-key --list-keys 3056513887B78AEB >/dev/null 2>&1; then
sudo pacman-key --delete 3056513887B78AEB

View File

@@ -1,3 +1,3 @@
echo "Add back ttf-ia-writer if it was missing"
pkg-add ttf-ia-writer
omarchy-pkg-add ttf-ia-writer

View File

@@ -1,4 +1,4 @@
echo "Replace JetBrains Mono font with the Nerd Font edition"
pkg-add ttf-jetbrains-mono-nerd
pkg-remove ttf-jetbrains-mono
omarchy-pkg-add ttf-jetbrains-mono-nerd
omarchy-pkg-drop ttf-jetbrains-mono

View File

@@ -1,3 +1,3 @@
echo "Add Samba network drive support to the file manager"
pkg-add gvfs-smb
omarchy-pkg-add gvfs-smb