Issue
I want to find out if the default browser is Google Chrome on a Mac OS X machine before the script executes.
How can I do it? thanks!
Solution
You can grep/awk
the launch services preferences list to find out which browser is set as default:
x=~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist; \
plutil -convert xml1 $x; \
grep 'https' -b3 $x | awk 'NR==2 {split($2, arr, "[><]"); print arr[3]}'; \
plutil -convert binary1 $x
This sets a variable (x
) to the launch services preferences list, then converts it using plutil
to xml
format so we can grep
it. We locate the string we're looking for (https
) then output the result. The final step is to convert the plist back to binary
format.
If chrome is set to be default you will get:
Result:
com.google.chrome
Answered By - l'L'l Answer Checked By - Timothy Miller (WPSolving Admin)