Use Omarchy command helpers consistently

This commit is contained in:
David Heinemeier Hansson
2026-07-18 10:08:43 -07:00
parent bd34704f7b
commit 8862fb22bd
23 changed files with 54 additions and 46 deletions
+3 -3
View File
@@ -22,7 +22,7 @@
OUTPUT_DIR="${OMARCHY_SCREENRECORD_DIR:-${XDG_VIDEOS_DIR:-$HOME/Videos}}"
if [[ ! -d $OUTPUT_DIR ]]; then
notify-send "Screen recording directory does not exist: $OUTPUT_DIR" -u critical -t 3000
omarchy-notification-send -u critical -t 3000 "Screen recording directory does not exist: $OUTPUT_DIR"
exit 1
fi
@@ -65,7 +65,7 @@ start_webcam_overlay() {
if [[ -z $WEBCAM_DEVICE ]]; then
WEBCAM_DEVICE=$(v4l2-ctl --list-devices 2>/dev/null | grep -m1 "^[[:space:]]*/dev/video" | tr -d '\t')
if [[ -z $WEBCAM_DEVICE ]]; then
notify-send "No webcam devices found" -u critical -t 3000
omarchy-notification-send -u critical -t 3000 "No webcam devices found"
return 1
fi
fi
@@ -200,7 +200,7 @@ stop_screenrecording() {
if pgrep -f "^gpu-screen-recorder" >/dev/null; then
pkill -9 -f "^gpu-screen-recorder"
notify-send "Screen recording error" "Recording process had to be force-killed. Video may be corrupted." -u critical -t 5000
omarchy-notification-send -u critical -t 5000 "Screen recording error" "Recording process had to be force-killed. Video may be corrupted."
else
finalize_recording
local filename=$(cat "$RECORDING_FILE" 2>/dev/null)
+5 -11
View File
@@ -29,13 +29,7 @@ provider_from_arg() {
}
self_path() {
local self="${BASH_SOURCE[0]}"
if [[ $self != /* ]]; then
self=$(command -v -- "$self")
fi
readlink -f "$self"
readlink -f "$OMARCHY_PATH/bin/${BASH_SOURCE[0]##*/}"
}
require_root() {
@@ -43,7 +37,7 @@ require_root() {
return
fi
if ! command -v pkexec >/dev/null; then
if omarchy-cmd-missing pkexec; then
echo "Error: pkexec is required to change DNS settings." >&2
exit 1
fi
@@ -156,7 +150,7 @@ set_connection_dns() {
local ipv4_dns="${1:-}"
local ipv6_dns="${2:-}"
command -v nmcli >/dev/null 2>&1 || return 0
omarchy-cmd-present nmcli || return 0
while IFS=: read -r uuid type; do
[[ -n $uuid ]] || continue
@@ -174,7 +168,7 @@ set_connection_dns() {
clear_connection_dns() {
local uuid type
command -v nmcli >/dev/null 2>&1 || return 0
omarchy-cmd-present nmcli || return 0
while IFS=: read -r uuid type; do
[[ -n $uuid ]] || continue
@@ -192,7 +186,7 @@ clear_connection_dns() {
reapply_active_dns_connections() {
local device type state
command -v nmcli >/dev/null 2>&1 || return 0
omarchy-cmd-present nmcli || return 0
while IFS=: read -r device type state; do
[[ -n $device && $state == connected ]] || continue
+3 -3
View File
@@ -54,12 +54,12 @@ log_first_run() {
}
notification_server_ready() {
if command -v gdbus >/dev/null 2>&1; then
if omarchy-cmd-present gdbus; then
gdbus call --session \
--dest org.freedesktop.Notifications \
--object-path /org/freedesktop/Notifications \
--method org.freedesktop.Notifications.GetServerInformation >/dev/null 2>&1
elif command -v busctl >/dev/null 2>&1; then
elif omarchy-cmd-present busctl; then
busctl --user call \
org.freedesktop.Notifications \
/org/freedesktop/Notifications \
@@ -71,7 +71,7 @@ notification_server_ready() {
}
wait_for_notifications() {
command -v omarchy-shell >/dev/null || return 0
omarchy-cmd-present omarchy-shell || return 0
for _ in {1..100}; do
if omarchy-shell notifications ping >/dev/null 2>&1 && notification_server_ready; then
+1 -1
View File
@@ -21,7 +21,7 @@ fi
# When --no-rebuild is set, the caller is responsible for the UKI rebuild
# (e.g. running before limine-mkinitcpio-hook is installed during initial
# install), so we only require limine-mkinitcpio when we'd invoke it ourselves.
if ! $NO_REBUILD && ! command -v limine-mkinitcpio &>/dev/null; then
if ! $NO_REBUILD && omarchy-cmd-missing limine-mkinitcpio; then
echo "Skipping hibernation setup (requires Limine bootloader)"
exit 0
fi
+1 -1
View File
@@ -2,7 +2,7 @@
# omarchy:summary=Detect whether the system has an active hybrid GPU configuration
if command -v supergfxctl &>/dev/null; then
if omarchy-cmd-present supergfxctl; then
supergfxctl -s 2>/dev/null | grep -qw Hybrid
else
(($(lspci | grep -cE 'VGA|3D|Display') >= 2))
+7 -6
View File
@@ -2,7 +2,7 @@
# omarchy:summary=Launch the Omarchy screensaver in the default terminal on the system with the correct font configuration.
if ! command -v tte &>/dev/null; then
if omarchy-cmd-missing tte; then
exit 1
fi
@@ -22,7 +22,8 @@ hypr_focus_monitor() {
}
hypr_exec() {
local command="$1"
local command
printf -v command '%q ' "$@"
hyprctl dispatch "hl.dsp.exec_cmd([[$command]])" >/dev/null 2>&1 || hyprctl dispatch exec -- bash -lc "$command" >/dev/null
}
@@ -32,16 +33,16 @@ for m in $(hyprctl monitors -j | jq -r '.[] | .name'); do
case $terminal in
*Alacritty*)
hypr_exec "alacritty --class=org.omarchy.screensaver --config-file $OMARCHY_PATH/default/alacritty/screensaver.toml -e omarchy-screensaver"
hypr_exec alacritty --class=org.omarchy.screensaver --config-file "$OMARCHY_PATH/default/alacritty/screensaver.toml" -e omarchy-screensaver
;;
*ghostty*)
hypr_exec "ghostty --class=org.omarchy.screensaver --config-file=$OMARCHY_PATH/default/ghostty/screensaver --font-size=18 -e omarchy-screensaver"
hypr_exec ghostty --class=org.omarchy.screensaver --config-file="$OMARCHY_PATH/default/ghostty/screensaver" --font-size=18 -e omarchy-screensaver
;;
*foot*)
hypr_exec "foot --app-id=org.omarchy.screensaver --config=\"$OMARCHY_PATH/default/foot/screensaver.ini\" -e omarchy-screensaver"
hypr_exec foot --app-id=org.omarchy.screensaver --config="$OMARCHY_PATH/default/foot/screensaver.ini" -e omarchy-screensaver
;;
*kitty*)
hypr_exec "kitty --class=org.omarchy.screensaver --override font_size=18 --override window_padding_width=0 -e omarchy-screensaver"
hypr_exec kitty --class=org.omarchy.screensaver --override font_size=18 --override window_padding_width=0 -e omarchy-screensaver
;;
*)
omarchy-notification-send -g ✋ "Screensaver only runs in Alacritty, Foot, Ghostty, or Kitty"
+1 -1
View File
@@ -15,7 +15,7 @@ fi
notify_command=$(printf 'if [[ -n $(omarchy-notification-send -u critical -g  "Run Omarchy Migrations" %q -a) ]]; then omarchy-launch-floating-terminal-with-presentation omarchy-migrate; fi' "$message")
if command -v systemd-run >/dev/null 2>&1; then
if omarchy-cmd-present systemd-run; then
unit="omarchy-migrations-notification-$(date +%Y%m%d%H%M%S)"
systemd-run --user --scope --unit="$unit" bash -lc "$notify_command" >/dev/null 2>&1 && exit 0
fi
+2 -2
View File
@@ -52,7 +52,7 @@ fail() {
}
require_command() {
command -v "$1" >/dev/null 2>&1 || fail "$1 is required"
omarchy-cmd-present "$1" || fail "$1 is required"
}
interactive() {
@@ -283,7 +283,7 @@ update_one() {
if (( ! ASSUME_YES )); then
echo "Changes for $id:"
if command -v delta >/dev/null 2>&1; then
if omarchy-cmd-present delta; then
git -C "$dir" diff HEAD FETCH_HEAD | delta --paging=never
else
git -C "$dir" diff HEAD FETCH_HEAD
+1 -1
View File
@@ -15,7 +15,7 @@
set -o pipefail
OMARCHY_PATH="${OMARCHY_PATH:-}"
command -v jq >/dev/null 2>&1 || { echo "omarchy-plugin-catalog: jq is required" >&2; exit 1; }
omarchy-cmd-present jq || { echo "omarchy-plugin-catalog: jq is required" >&2; exit 1; }
paths=()
+1 -1
View File
@@ -15,7 +15,7 @@ fail() {
}
require_command() {
command -v "$1" >/dev/null 2>&1 || fail "$1 is required"
omarchy-cmd-present "$1" || fail "$1 is required"
}
require_omarchy_path() {
+1 -1
View File
@@ -28,7 +28,7 @@ USAGE
exit 0
fi
command -v jq >/dev/null 2>&1 || fail "jq is required"
omarchy-cmd-present jq || fail "jq is required"
PLUGIN_DIR="${1:-}"
[[ -n $PLUGIN_DIR && -d $PLUGIN_DIR ]] || fail "plugin folder not found: ${PLUGIN_DIR:-<none>}"
+2 -2
View File
@@ -3,10 +3,10 @@
# omarchy:summary=Overwrite the user config for the Plymouth drive decryption and boot sequence with the Omarchy default and rebuild it.
# omarchy:requires-sudo=true
sudo cp -r $OMARCHY_PATH/default/plymouth/* /usr/share/plymouth/themes/omarchy/
sudo cp -r "$OMARCHY_PATH/default/plymouth/." /usr/share/plymouth/themes/omarchy/
sudo plymouth-set-default-theme omarchy
if command -v limine-mkinitcpio &>/dev/null; then
if omarchy-cmd-present limine-mkinitcpio; then
sudo limine-mkinitcpio
else
sudo mkinitcpio -P
+1 -1
View File
@@ -6,7 +6,7 @@
set -e
if command -v flatpak >/dev/null && flatpak info com.nvidia.geforcenow &>/dev/null; then
if omarchy-cmd-present flatpak && flatpak info com.nvidia.geforcenow &>/dev/null; then
flatpak uninstall -y --delete-data com.nvidia.geforcenow
fi
+1 -1
View File
@@ -91,7 +91,7 @@ if package_name="$(pacman -Qqo "$desktop_file" 2>/dev/null | head -1)" && [[ -n
exec omarchy-launch-floating-terminal-with-presentation "echo Uninstalling $quoted_display...; sudo pacman -Rns $quoted_package"
fi
if command -v flatpak >/dev/null 2>&1 && flatpak info "${desktop_file_name%.desktop}" >/dev/null 2>&1; then
if omarchy-cmd-present flatpak && flatpak info "${desktop_file_name%.desktop}" >/dev/null 2>&1; then
flatpak_id="${desktop_file_name%.desktop}"
quoted_flatpak="$(printf '%q' "$flatpak_id")"
exec omarchy-launch-floating-terminal-with-presentation "flatpak uninstall $quoted_flatpak"
+1 -1
View File
@@ -13,7 +13,7 @@ if [[ -z $COMMAND ]]; then
exit 1
fi
if ! command -v snapper &>/dev/null; then
if omarchy-cmd-missing snapper; then
exit 127 # omarchy-update can use this to just ignore if snapper is not available
fi
+1 -1
View File
@@ -12,7 +12,7 @@ hyprctl switchxkblayout all 0 > /dev/null 2>&1
# Ensure 1password is locked. Use timeout because `1password --lock` can
# otherwise leave a full Electron helper tree running after each lock.
if pgrep -x "1password" >/dev/null && command -v 1password >/dev/null 2>&1; then
if pgrep -x "1password" >/dev/null && omarchy-cmd-present 1password; then
(
flock -n 9 || exit 0
timeout --kill-after=1s 3s 1password --lock >/dev/null 2>&1 || true
+2 -4
View File
@@ -8,8 +8,7 @@ monitor_command='exec dbus-monitor --system "type='\''signal'\'',sender='\''org.
consume_sleep_events() {
local line sleep_lock
sleep_lock=$(command -v omarchy-system-sleep-lock || true)
sleep_lock=${sleep_lock:-/usr/bin/omarchy-system-sleep-lock}
sleep_lock="$OMARCHY_PATH/bin/omarchy-system-sleep-lock"
while IFS= read -r line; do
if [[ $line == *"boolean true"* ]]; then
@@ -24,8 +23,7 @@ if [[ ${1:-} == "--consume" ]]; then
exit 0
fi
sleep_monitor=$(command -v omarchy-system-sleep-monitor || true)
sleep_monitor=${sleep_monitor:-/usr/bin/omarchy-system-sleep-monitor}
sleep_monitor="$OMARCHY_PATH/bin/omarchy-system-sleep-monitor"
exec systemd-inhibit \
--what=sleep \
+1 -1
View File
@@ -30,7 +30,7 @@ for file in "${tui_desktop_files[@]}"; do
rm -f "$ICON_DIR/$icon_name.png" "$ICON_DIR/$app_name.png" "$OLD_ICON_DIR/$app_name.png"
done
if command -v update-desktop-database &>/dev/null; then
if omarchy-cmd-present update-desktop-database; then
update-desktop-database "$APP_DIR" &>/dev/null || true
fi
+1 -1
View File
@@ -38,7 +38,7 @@ update_disabled_idle=0
sleep_inhibit_pid=""
disable_sleep_for_update() {
command -v systemd-inhibit >/dev/null 2>&1 || return 0
omarchy-cmd-present systemd-inhibit || return 0
systemd-inhibit \
--what=sleep:idle \
+1 -1
View File
@@ -9,7 +9,7 @@ TEMP_LOG="/tmp/upload-log.txt"
SYSTEM_INFO="/tmp/system-info.txt"
# Get system information if fastfetch is available
if command -v fastfetch >/dev/null 2>&1; then
if omarchy-cmd-present fastfetch; then
{
echo "========================================="
echo "SYSTEM INFORMATION"
+1 -1
View File
@@ -30,7 +30,7 @@ for file in "${webapp_desktop_files[@]}"; do
rm -f "$ICON_DIR/$icon_name.png" "$ICON_DIR/$app_name.png" "$OLD_ICON_DIR/$app_name.png"
done
if command -v update-desktop-database &>/dev/null; then
if omarchy-cmd-present update-desktop-database; then
update-desktop-database "$APP_DIR" &>/dev/null || true
fi
+1 -1
View File
@@ -294,7 +294,7 @@ launch_windows() {
echo "❌ Failed to start Windows VM!"
echo " Try checking: omarchy-windows-vm status"
echo " View logs: docker logs omarchy-windows"
notify-send -u critical "Windows VM" "Failed to start Windows VM"
omarchy-notification-send -u critical "Windows VM" "Failed to start Windows VM"
exit 1
fi
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
set -euo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
raw_command_checks=$(rg -l 'command -v' "$ROOT/bin" \
| rg -v '/omarchy-(cmd-|pkg-|upgrade-to-quattro)' || true)
[[ -z $raw_command_checks ]] || fail "bin commands use command helpers" "$raw_command_checks"
pass "bin commands use command helpers"
raw_notifications=$(rg -l -P '^[[:space:]]*[^#[:space:]].*\bnotify-send\b' "$ROOT/bin" \
| rg -v '/omarchy-notification-send$' || true)
[[ -z $raw_notifications ]] || fail "bin commands use the notification helper" "$raw_notifications"
pass "bin commands use the notification helper"