Surfin' Safari

brockwalters
Contributor II

Surfin'SafariCover.jpg

It is an objective fact that the Beach Boys are one of the 5 most overrated bands of all time, however, that discussion will have to wait for another time & place...

It is fun when you can still do something slightly interesting with .plist modification. To wit: a thing for the customizing the toolbar in Safari. I am not going to make a script, I'll leave that to you, but, here are the raw ingredients:

 

1. 

crntusr=$(stat -f %Su /dev/console)

2. 

sudo -u "$crntusr" defaults read /System/Volumes/Data/Users/"$crntusr"/Library/Containers/com.apple.Safari/Data/Library/Preferences/com.apple.Safari.plist 'NSToolbar Configuration BrowserStandaloneTabBarToolbarIdentifier'

3.

sudo pkill -ail Safari

4.

sudo -u "$crntusr" /usr/libexec/PlistBuddy -c "add 'NSToolbar Configuration BrowserStandaloneTabBarToolbarIdentifier':'TB Item Identifiers':4 string HomeToolbarIdentifier" /System/Volumes/Data/Users/"$crntusr"/Library/Containers/com.apple.Safari/Data/Library/Preferences/com.apple.Safari.plist

5.

open /System/Applications/Safari.app

 

1. current user (however you get that...) because Safari preferences are in the user domain

2. read the .plist with defaults (you can also read it with PlistBuddy)

3. make sure Safari is not running when this change is made

4. The PlistBuddy syntax (as always) is a little challenging, but, what's happening is:

  • an entry is created in the 'NSToolbar Configuration BrowserStandaloneTabBarToolbarIdentifier':'TB Item Identifiers' array
  • in this example the Home page button is added
  • an index is chosen for where the button should be positioned relative to what is already on the toolbar
  • the index order is from left to right

5. open Safari & marvel at how computers work...

Before:

Screen Shot 2022-06-03 at 3.25.13 PM.png

After:

after.png

Enjoy!

1 REPLY 1

Bol
Valued Contributor

- I followed along at home and enjoyed myself :D
- Greatest time period for music creation.. 90's :D 
- Kudos to you!