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"