* Offer to reboot when toggling sudoless Docker; show only the relevant menu entry Group membership only takes effect on a fresh session, and in practice a logout or newgrp isn't enough — only a reboot reliably applies it. So the setup/remove commands now flag the reboot and offer to do it now with a gum confirm (like the GPU toggle), and the notices say "after a reboot" instead of pointing at logout or newgrp. The existing-user migration passes OMARCHY_DEFER_REBOOT so it does not prompt mid-update — omarchy-update-restart still handles the reboot once the whole update finishes. The Setup > Security menu also showed Sudoless Docker under both Setup and Remove. Condition the Setup entry on the group being absent (Remove already conditions on it being present), so only the applicable one appears. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gb7x6poap4hGCndPx5qt5T * Ask omarchy-sudo-docker whether Docker needs sudo Every place that chooses between talking to Docker directly and elevating was testing group membership by hand, and the menu guards tested the wrong thing: they read the running session's groups, which do not change until the reboot, so after enabling sudoless Docker the menu still offered Setup — the one action that could no longer do anything — while Remove stayed hidden. Add omarchy-sudo-docker as the single answer, with the two questions that actually differ in that window. By default it asks whether this session can reach the socket, which is what decides if a command must elevate: lazydocker and the Windows VM keep prompting until the reboot lands. With --configured it asks whether the account is set up for sudoless Docker, which is what the menu and the toggles need, so the menu switches to the action that can change state as soon as the group is written. Also correct a comment: nothing surfaces reboot-required in the bar; it is omarchy-update-restart that reads it during a later update. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gb7x6poap4hGCndPx5qt5T --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
1.8 KiB
Bash
Executable File
45 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Succeed when Docker needs sudo, fail when it can be used directly
|
|
# omarchy:args=[--configured]
|
|
# omarchy:examples=omarchy-sudo-docker && echo "needs sudo" | omarchy-sudo-docker --configured
|
|
# omarchy:hidden=true
|
|
|
|
# The docker group is root-equivalent, so Omarchy leaves users out of it by
|
|
# default and reaches the daemon through a prompt instead. Everything that has
|
|
# to make that choice asks here rather than testing group membership itself.
|
|
#
|
|
# Two questions, because they have different answers between toggling sudoless
|
|
# Docker and the reboot that applies it (group membership is fixed when the
|
|
# session is created):
|
|
#
|
|
# (default) Does Docker need sudo *right now*? Answered by whether this
|
|
# process can actually reach the socket, which is what decides
|
|
# if a command must elevate. Still true in the window after
|
|
# sudoless Docker is enabled but before the reboot.
|
|
# --configured Will it need sudo once the account's groups take effect?
|
|
# Answered from the account's configured groups, so the menu
|
|
# offers the toggle that can actually change state.
|
|
#
|
|
# Succeeds (exit 0) when sudo is needed, so it reads as `if omarchy-sudo-docker`.
|
|
|
|
DOCKER_SOCKET="${OMARCHY_DOCKER_SOCKET:-/var/run/docker.sock}"
|
|
|
|
case "${1:-}" in
|
|
--configured)
|
|
# An account in the docker group will not need sudo after the next login.
|
|
id -nG "$USER" 2>/dev/null | grep -qw docker && exit 1
|
|
exit 0
|
|
;;
|
|
"")
|
|
# A socket we can write is a daemon we can drive without elevating. A missing
|
|
# socket counts as needing sudo: reaching it means starting it as root anyway.
|
|
[[ -w $DOCKER_SOCKET ]] && exit 1
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Usage: omarchy-sudo-docker [--configured]" >&2
|
|
exit 2
|
|
;;
|
|
esac
|