Configure Trackpad Settings on macOS
Managing trackpad settings across your MacFleet ensures consistent user experience and productivity. This tutorial covers common trackpad configurations using shell scripts for enterprise deployment.
Understanding Trackpad Settings
The trackpad settings are stored in the com.apple.AppleMultitouchTrackpad
preference domain and require user context for proper application.
Basic User Context Function
All trackpad scripts require proper user context:
#!/bin/bash
# Get current logged-in user
get_current_user() {
/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'
}
# Execute command in user context
execute_as_user() {
local user="$1"
local command="$2"
su -l "$user" -c "$command"
}
Tracking Speed Configuration
Set Tracking Speed
#!/bin/bash
loggedInUser=$(get_current_user)
# Set tracking speed (0.0 to 3.0)
# 0.0 = Slow, 1.5 = Medium, 3.0 = Fast
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad TrackingSpeed -float 1.5"
launchctl bootout user/$(id -u $loggedInUser)
Click Configuration
Set Click Pressure
#!/bin/bash
loggedInUser=$(get_current_user)
# Click options: 0 = Light, 1 = Medium, 2 = Firm
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad FirstClickThreshold -int 1"
launchctl bootout user/$(id -u $loggedInUser)
Enable Silent Clicking
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad ActuationStrength -int 0"
launchctl bootout user/$(id -u $loggedInUser)
Tap to Click Settings
Enable Tap to Click
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true"
launchctl bootout user/$(id -u $loggedInUser)
Disable Tap to Click
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad Clicking -bool false"
launchctl bootout user/$(id -u $loggedInUser)
Secondary Click (Right-Click)
Enable Two-Finger Secondary Click
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad TrackpadRightClick -bool true"
launchctl bootout user/$(id -u $loggedInUser)
Natural Scrolling
Enable Natural Scrolling
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad TrackpadScroll -bool true"
launchctl bootout user/$(id -u $loggedInUser)
Disable Natural Scrolling
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad TrackpadScroll -bool false"
launchctl bootout user/$(id -u $loggedInUser)
Look Up Feature
Disable Look Up (Three-Finger Tap)
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad ForceSuppressed -bool true"
launchctl bootout user/$(id -u $loggedInUser)
Enable Look Up
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad ForceSuppressed -bool false"
launchctl bootout user/$(id -u $loggedInUser)
Drag Lock Configuration
Enable Drag Lock
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad Dragging -bool true"
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad DragLock -bool true"
launchctl bootout user/$(id -u $loggedInUser)
Disable Drag Lock
#!/bin/bash
loggedInUser=$(get_current_user)
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad Dragging -bool false"
execute_as_user "$loggedInUser" "defaults write com.apple.AppleMultitouchTrackpad DragLock -bool false"
launchctl bootout user/$(id -u $loggedInUser)
Enterprise Configuration Script
Complete trackpad configuration for enterprise deployment:
#!/bin/bash
# Trackpad Configuration Script for MacFleet
# Compatible with macOS 10.14+
# Function to log messages
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a /var/log/trackpad_config.log
}
# Get current user
get_current_user() {
/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'
}
# Execute command in user context
execute_as_user() {
local user="$1"
local command="$2"
su -l "$user" -c "$command"
}
# Main configuration function
configure_trackpad() {
local current_user
current_user=$(get_current_user)
log_message "Starting trackpad configuration for user: $current_user"
# Set tracking speed to medium
if execute_as_user "$current_user" "defaults write com.apple.AppleMultitouchTrackpad TrackingSpeed -float 1.5"; then
log_message "✓ Tracking speed set to medium"
else
log_message "✗ Failed to set tracking speed"
fi
# Enable tap to click
if execute_as_user "$current_user" "defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true"; then
log_message "✓ Tap to click enabled"
else
log_message "✗ Failed to enable tap to click"
fi
# Enable two-finger secondary click
if execute_as_user "$current_user" "defaults write com.apple.AppleMultitouchTrackpad TrackpadRightClick -bool true"; then
log_message "✓ Two-finger secondary click enabled"
else
log_message "✗ Failed to enable secondary click"
fi
# Enable natural scrolling
if execute_as_user "$current_user" "defaults write com.apple.AppleMultitouchTrackpad TrackpadScroll -bool true"; then
log_message "✓ Natural scrolling enabled"
else
log_message "✗ Failed to enable natural scrolling"
fi
# Set click pressure to medium
if execute_as_user "$current_user" "defaults write com.apple.AppleMultitouchTrackpad FirstClickThreshold -int 1"; then
log_message "✓ Click pressure set to medium"
else
log_message "✗ Failed to set click pressure"
fi
# Restart user session for changes to take effect
if launchctl bootout user/$(id -u $current_user) 2>/dev/null; then
log_message "✓ User session restarted"
else
log_message "! User session restart attempted"
fi
log_message "Trackpad configuration completed"
return 0
}
# Verification function
verify_configuration() {
local current_user
current_user=$(get_current_user)
log_message "Verifying trackpad configuration:"
local tracking_speed
tracking_speed=$(execute_as_user "$current_user" "defaults read com.apple.AppleMultitouchTrackpad TrackingSpeed 2>/dev/null" || echo "not set")
log_message " Tracking Speed: $tracking_speed"
local tap_click
tap_click=$(execute_as_user "$current_user" "defaults read com.apple.AppleMultitouchTrackpad Clicking 2>/dev/null" || echo "not set")
log_message " Tap to Click: $tap_click"
local right_click
right_click=$(execute_as_user "$current_user" "defaults read com.apple.AppleMultitouchTrackpad TrackpadRightClick 2>/dev/null" || echo "not set")
log_message " Secondary Click: $right_click"
}
# Execute main function
if configure_trackpad; then
verify_configuration
log_message "Script executed successfully"
exit 0
else
log_message "Script execution failed"
exit 1
fi
Verification Script
Check current trackpad settings:
#!/bin/bash
current_user=$(get_current_user)
echo "=== Trackpad Settings Status ==="
echo "Tracking Speed: $(su -l "$current_user" -c "defaults read com.apple.AppleMultitouchTrackpad TrackingSpeed 2>/dev/null" || echo 'Not configured')"
echo "Tap to Click: $(su -l "$current_user" -c "defaults read com.apple.AppleMultitouchTrackpad Clicking 2>/dev/null" || echo 'Not configured')"
echo "Secondary Click: $(su -l "$current_user" -c "defaults read com.apple.AppleMultitouchTrackpad TrackpadRightClick 2>/dev/null" || echo 'Not configured')"
echo "Natural Scrolling: $(su -l "$current_user" -c "defaults read com.apple.AppleMultitouchTrackpad TrackpadScroll 2>/dev/null" || echo 'Not configured')"
echo "Drag Lock: $(su -l "$current_user" -c "defaults read com.apple.AppleMultitouchTrackpad DragLock 2>/dev/null" || echo 'Not configured')"
Troubleshooting
Issue | Solution |
---|---|
Settings don't apply | Ensure script runs with proper user context |
Changes revert | Use launchctl bootout to restart user session |
Permission denied | Run script with admin privileges |
Settings not visible | Restart System Preferences app |
Reference Values
Tracking Speed
0.0
- Slow1.5
- Medium (recommended)3.0
- Fast
Click Pressure
0
- Light click1
- Medium click (recommended)2
- Firm click
Important Notes
- All trackpad settings require user session restart to take effect
- Use
launchctl bootout user/$(id -u $user)
to restart the user session - Test settings on a small group before enterprise-wide deployment
- Users can manually override these settings in System Preferences