macOS Setup
Background
MouseHero uses the shutdown command to power off and restart your system. On macOS, this requires sudo privileges. This guide provides a one-click script to configure passwordless execution for shutdown.
How to Set Up
Save the script below as a bash file and execute it. It will automatically configure passwordless shutdown for the current user.
#!/usr/bin/env bash
set -euo pipefail
USER_NAME="$USER"
SUDOERS_FILE="/etc/sudoers.d/mousehero"
SHUTDOWN_PATH=$(which shutdown)
if [[ -z "$SHUTDOWN_PATH" ]]; then
echo "❌ 'shutdown' command not found. Please ensure your system is functioning correctly." >&2
exit 1
fi
echo "==> Configuring '$SHUTDOWN_PATH' for user '$USER_NAME'..."
sudo tee "$SUDOERS_FILE" > /dev/null <<EOF
# MouseHero sudoers rule (managed by script)
$USER_NAME ALL=(root) NOPASSWD: $SHUTDOWN_PATH
EOF
sudo chmod 0440 "$SUDOERS_FILE"
if sudo visudo -c; then
echo "✅ Success."
else
echo "❌ Failed to validate sudoers file."
sudo rm -f "$SUDOERS_FILE"
exit 1
fi
How to Verify
Execute sudo shutdown -h +10. If you are not prompted for a password and a broadcast message appears stating the system will shut down in 10 minutes, the setup is successful. This command will not actually shut down your computer.
How to Uninstall
To remove the configuration, execute:
sudo rm -f /etc/sudoers.d/mousehero