Fix macOS menu bar spacing configuration to use activation scripts

- Replace CustomUserPreferences with system.activationScripts.postUserActivation
- Use defaults -currentHost write commands that actually work
- Corrected values: NSStatusItemSpacing=12, NSStatusItemSelectionPadding=6
- Commands will run during darwin-rebuild to apply host-specific preferences

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Yan Lin 2025-07-30 18:24:20 +02:00
parent 052a8d74e6
commit d661a80fa9
2 changed files with 23 additions and 19 deletions

View file

@ -97,6 +97,16 @@ create_directory "$PAPER_PATH" "paper"
[ -n "$CONTENT_PATH" ] && [ "$CONTENT_PATH" != "null" ] && [ -d "$CONTENT_PATH" ] && zoxide add "$CONTENT_PATH" 2>/dev/null || true
[ -n "$PAPER_PATH" ] && [ "$PAPER_PATH" != "null" ] && [ -d "$PAPER_PATH" ] && zoxide add "$PAPER_PATH" 2>/dev/null || true
# Check if session already exists and attach if it does
if is_session_running "$SESSION_NAME"; then
printf "\033[1;32mAttaching to existing session: %s\033[0m\n" "$SESSION_NAME"
tmux attach-session -t "$SESSION_NAME"
exit 0
fi
# Update papis cache
papis cache reset > /dev/null 2>&1
# Create remote directory if server connection is configured
if [ -n "$SERVER" ] && [ -n "$REMOTE_DIR" ]; then
printf "\033[2mEnsuring remote directory exists: %s:%s\033[0m\n" "$SERVER" "$REMOTE_DIR"
@ -108,16 +118,6 @@ if [ -n "$SERVER" ] && [ -n "$REMOTE_DIR" ]; then
fi
fi
# Check if session already exists and attach if it does
if is_session_running "$SESSION_NAME"; then
printf "\033[1;32mAttaching to existing session: %s\033[0m\n" "$SESSION_NAME"
tmux attach-session -t "$SESSION_NAME"
exit 0
fi
# Update papis cache
papis cache reset > /dev/null 2>&1
# Launch appropriate template
case "$TEMPLATE" in
"basic")

View file

@ -1,12 +1,16 @@
{ config, pkgs, ... }:
{
system.defaults.NSGlobalDomain = {
# Menu bar spacing configuration
# Set primary user for system preferences
system.primaryUser = "yanlin";
# Menu bar spacing configuration using activation scripts
# Uses -currentHost to write host-specific preferences
# NSStatusItemSpacing controls horizontal spacing between menu bar items
# NSStatusItemSelectionPadding controls padding inside selection overlay
# Optimal ratio is 1:2 (spacing:padding)
NSStatusItemSpacing = 6;
NSStatusItemSelectionPadding = 12;
};
system.activationScripts.postUserActivation.text = ''
echo "Setting menu bar spacing preferences..."
defaults -currentHost write -globalDomain NSStatusItemSpacing -int 12
defaults -currentHost write -globalDomain NSStatusItemSelectionPadding -int 6
'';
}