From f12abbdebb96c316455fb31f654088123f409809 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 22 Jul 2026 16:45:17 -0700 Subject: [PATCH] Use sudo for terminal DNS changes and drop needless command checks Co-Authored-By: Claude Fable 5 --- bin/omarchy-dns | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/bin/omarchy-dns b/bin/omarchy-dns index 078b2a19..4e031678 100755 --- a/bin/omarchy-dns +++ b/bin/omarchy-dns @@ -37,12 +37,11 @@ require_root() { return fi - if omarchy-cmd-missing pkexec; then - echo "Error: pkexec is required to change DNS settings." >&2 - exit 1 + if [[ -t 0 ]]; then + exec sudo "$(self_path)" "$@" + else + exec pkexec "$(self_path)" "$@" fi - - exec pkexec "$(self_path)" "$@" } networkmanager_global_dns() { @@ -150,8 +149,6 @@ set_connection_dns() { local ipv4_dns="${1:-}" local ipv6_dns="${2:-}" - omarchy-cmd-present nmcli || return 0 - while IFS=: read -r uuid type; do [[ -n $uuid ]] || continue networkmanager_dns_connection "$type" || continue @@ -168,8 +165,6 @@ set_connection_dns() { clear_connection_dns() { local uuid type - omarchy-cmd-present nmcli || return 0 - while IFS=: read -r uuid type; do [[ -n $uuid ]] || continue networkmanager_dns_connection "$type" || continue @@ -186,8 +181,6 @@ clear_connection_dns() { reapply_active_dns_connections() { local device type state - omarchy-cmd-present nmcli || return 0 - while IFS=: read -r device type state; do [[ -n $device && $state == connected ]] || continue case "$type" in