Make preferences changes take effect immediately from CLI

defaultssystem-prefs

How you can make changes take effect and update in the Preferences GUI immediately without having to reboot (unacceptable), log out (bad) or kill processes (last resort)? macOS 10.12

defaults write ~/Library/Preferences/.GlobalPreferences.plist com.apple.swipescrolldirection -bool NO
sudo defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.plist LocationServicesEnabled -bool NO

Update:

  • Restarting Finder updates swipe GUI, but not the swiping itself! How can this be done?
  • Location services: Updates instantly now. (Must have been something wrong before.)

Best Answer

Send the System Preferences process a signal called the 'hang-up' or HUP, also known as signal number 1 as defined somewhere in a system signals.h header file. POSIX convention, I believe.

The quick and dirty:

sudo pkill -1 'System Preferences'

Replace System Preferences with Finder, or the PID of a relevant process. Another quick and dirty:

for STALE in Finder Preferences locationd ; do sudo pkill -1 $( pgrep ${STALE} ) ; done

What a HUP signal should effectuate in the receiving process is an internal halt and re-evaluation, which usually includes a re-reading of any relevant config files. The process will not terminate, only 'refresh' itself.

Hope this helps.

F.