1

I'm a CLI enthusiast and, as such, I've been a extensive user of brew, cask, m, mas, softwareupdate and so on. I've even written some tutorials about them (check here and there).

Right now, I'm diving into defaults to alter my settings.

My problem is that some defaults set in CLI don't appear in GUI. For instance, I try to deactivate "three fingers lookup & data detectors" in System Preferences > Trackpad

enter image description here

Using diff and defaults read, I found that the settings is "TrackpadThreeFingerTapGesture" in "com.apple.AppleMultitouchTrackpad".

When the checkbox is checked, "defaults read com.apple.AppleMultitouchTrackpad TrackpadThreeFingerTapGesture" returns 2. That's the default value. When it's no checked, it returns 0. That's what I want.

To test this out, I checked the setting in the GUI, then used these commands:

killall 'System Preferences'
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerTapGesture -int 0
defaults read com.apple.AppleMultitouchTrackpad TrackpadThreeFingerTapGesture

The last commands returns 0, which is ok. But when I open the GUI, the checkbox is still checked! Reading the value again still gives me 0...

I even tried logging out after altering the value, the problem remains.

Can someone help?

1

The preference you wish to set is saved in ~/Library/Preferences/ByHost, so you have to add the switch -currentHost to the defaults command

Try the following code with Value set to 0, then set to 2 and see the difference

Value="0"; \
echo "before"; \
: read actual values; \
defaults -currentHost read -g "com.apple.trackpad.threeFingerTapGesture"; \
defaults read com.apple.AppleMultitouchTrackpad TrackpadThreeFingerTapGesture; \
: close System Preferenes; \
pkill -u "${USER}" \
      -f "^/Applications/System Preferences.app/Contents/MacOS/System Preferences$" 2>/dev/null; \
: set value in ~/Library/Preferences/ByHost/.GlobalPreferences.#Hardware UUID#.plist; \
: where your hardware uuid can be determined with; \
: ioreg -c IOPlatformExpertDevice  -d 2 | awk -F'"' '/IOPlatformUUID/ { print $(NF-1) }'; \
defaults -currentHost write -g "com.apple.trackpad.threeFingerTapGesture" -integer ${Value}; \
: set value in ~/Library/Preferences/.GlobalPreferences.plist; \
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerTapGesture -integer ${Value}; \
: kill the preference cache process; \
pkill -u "${USER}" -l "^/usr/sbin/cfprefsd agent$" 2>/dev/null; \
: wait a second otherwise you get errors on the defaults commands; \
sleep 1; \
echo "after"; \
: read set values; \
defaults -currentHost read -g "com.apple.trackpad.threeFingerTapGesture"; \
defaults read com.apple.AppleMultitouchTrackpad TrackpadThreeFingerTapGesture; \
: open trackpad preference; \
open "/System/Library/PreferencePanes/Trackpad.prefPane"

gives me

before
2
2
after
0
0

regards

Gerd

  • I can't believe my problem has been solved after so much time! Thanks a lo!! – X99 Jan 17 at 19:28
0

My friend, I believe that you might be a mere 'hang-up' or 'HUP' signal away from realising your desires. 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'

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.

  • Doesn't help, the checkbox is still checked. Thanks for the idea though ;) – X99 Sep 14 '18 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .