My run0 sudo-less system works without any issues ![]()
Below is a refined installation procedure.
Here are two systemd services: one that grants passwordless access to the local $USER for 15 minutes on any terminal, and another that removes it using a timer.
sudo removal
run0 pacman -Rnsc sudo
run0 pacman -Syu autoconf automake bison debugedit flex gc guile m4 make patch pkgconf fakeroot
# to restore:
# run0 pacman -Syu base-devel
Simple sudo wrapper for paru (without sudo), followed by an advanced one.
echo '#!/bin/bash\nrun0 "$@"' | run0 tee /usr/local/bin/sudo && run0 chmod +x /usr/local/bin/sudo
# Rust wrapper
paru run0-sudo-shim-git
run0 rm /usr/local/bin/sudo # simple removal
systemd services creation
run0 tee /etc/systemd/system/npc_run0.service << EOF
[Unit]
Before=shutdown.target reboot.target halt.target
[Service]
Type=oneshot
ExecStart=/usr/bin/rm -f /etc/polkit-1/rules.d/99-$USER.rules
ExecStop=/usr/bin/systemctl stop npc_run0.timer
[Install]
WantedBy=multi-user.target
EOF
run0 tee /etc/systemd/system/npc_run0.timer << EOF
[Timer]
OnActiveSec=930
Persistent=true
[Install]
WantedBy=timers.target
EOF
run0 tee /etc/systemd/system/np_run0.service << EOF
[Service]
Type=simple
ExecStart=/usr/bin/bash -c "echo 'polkit.addRule(function(action, subject) { if (action.id == \"org.freedesktop.systemd1.manage-units\" && subject.user == \"$USER\" && subject.local == true && subject.active == true ) { return polkit.Result.YES; } });' > /etc/polkit-1/rules.d/99-$USER.rules"
ExecStop=/usr/bin/systemctl restart npc_run0.timer
EOF
run0 systemctl daemon-reload
run0 systemctl enable npc_run0.service # enable for removal of passwordless access after reboot
.zshrc
(not-so-red background; automatically prolongs sudo-like access after use)
unalias sudo
sudo() { np >/dev/null; nocorrect run0 --background="48;2;255;244;244" "$@"; }
alias ro='run0 --background="48;2;255;244;244" zsh' # su alternative
alias run0='run0 --background="48;2;255;244;244"' # just not-so-red background
np() { systemctl start np_run0.service; } # no password
npc() { systemctl start npc_run0.service; } # cancel now
Timer prompt function for .p10k.zsh:
function prompt_npc_timer() {
local next_time=$(systemctl list-timers --no-legend 2>/dev/null | grep npc_run0 | awk '{print $5}')
[[ -z "$next_time" || "$next_time" == *":"* || "$next_time" == *"-"* ]] && return
p10k segment -f 232 -b 4 -i '⏰' -t "$next_time"
}
Just add the function somewhere and then add npc_timer to the left or right prompt to display e.g. ⏰ 9min, if passwordless access is granted
(e.g. inside typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( ... )).