From 506348ef4b72d6fea005e7a29d6496a4da5a3dbb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 15 Mar 2026 18:48:39 +0100 Subject: [PATCH] Clean up file if no timer is present --- bin/omarchy-sudo-passwordless-toggle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/omarchy-sudo-passwordless-toggle b/bin/omarchy-sudo-passwordless-toggle index a8857aa5..9757767b 100755 --- a/bin/omarchy-sudo-passwordless-toggle +++ b/bin/omarchy-sudo-passwordless-toggle @@ -7,6 +7,11 @@ NOPASSWD_FILE="/etc/sudoers.d/99-omarchy-nopasswd-${USER}" TIMER_NAME="omarchy-nopasswd-expire-${USER}" +# Safety: if the file exists but the timer doesn't (e.g. after reboot), clean up +if sudo test -f "$NOPASSWD_FILE" && ! systemctl is-active "${TIMER_NAME}.timer" &>/dev/null; then + sudo rm "$NOPASSWD_FILE" +fi + # Check for the file directly — sudo -n can stay cached or be granted by other rules if sudo test -f "$NOPASSWD_FILE"; then sudo rm "$NOPASSWD_FILE"