Posted on 08-01-2023 06:35 AM
I'm trying to follow the documentation for deploying SwiftDefaultApps in order to make Outlook the Default Mail Reader and Excel the default app for CSV files for our production fleet of over 300 MacBook Air M1's.
I'm using GitHub - Lord-Kamina/SwiftDefaultApps: Replacement for RCDefaultApps, written in Swift. for material. I am also referencing this article for deploying a script via policy Configuring a Mac’s Default Apps for Different File Types | apizz (wordpress.com).
Here's my dumbed down verison of the script from wordpress:
#!/bin/bash
# Set default apps for users
SWDA="/usr/local/bin/swda"
MAIL="/Applications/Microsoft Outlook.app"
SHEET="/Applications/Microsoft Excel.app"
### MAIL ###
# Default mail client
$SWDA setHandler --app "$MAIL" --mail
# mailto: links
$SWDA setHandler --app "$MAIL" --URL mailto
# message
$SWDA setHandler --app "$MAIL" --URL message
# email
$SWDA setHandler --app "$MAIL" --UTI com.apple.mail.email
### FILE TYPES ###
# .csv
$SWDA setHandler --app "$SHEET" --UTI public.comma-separated-values-text
The error I get after running is this below:
Im a novice in scripting so not sure if I need to make the "usr/local/bin/swda"? If I make that directory then I would get an error saying that "/usr/local/bin/swda: is a directory".
Any help here is appreciated.
Solved! Go to Solution.
Posted on 08-08-2023 06:46 AM
Ended up using MailToOutlook for Outlook and ran a script on each device to remove Numbers from it - this defaults all CSV files to Excel since there is no other app on the machine. An easy workaround as of right now.
08-01-2023 06:53 AM - edited 08-01-2023 06:54 AM
@ntavassoli You have to copy the swda executable to the Mac you want to run it on. To do that you'd:
Posted on 08-01-2023 07:33 AM
Sweet! Im on the right track I believe but when the policy runs it shows this error now:
Is there a way to trust this binary via Jamf so I dont run into this issue via deployment?
Posted on 08-01-2023 07:40 AM
@ntavassoli You need to clear the quarantine flag on the swda binary:
sudo xattr -d com.apple.quarantine /Path/to/swda
Posted on 08-01-2023 08:14 AM
So it runs successfully but no change is made on either of my test devices. The script shows this output:
Executing Policy Excel and Outlook set as Default
Downloading swda.pkg...
Downloading https://use1-jcds.services.jamfcloud.com//download/2e13a3a0b5bb4bd2b692b75c6965ff80/swda.pkg...
Verifying package integrity...
Installing swda.pkg...
Successfully installed swda.pkg.
Running script Set Excel and Outlook to default apps...
Script exit code: 0
Script result: SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Outlook
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Outlook
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Outlook
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Outlook
SwiftDefaultApps SUCCESS: Default handler has succesfully changed to com.microsoft.Excel
Posted on 08-01-2023 08:15 AM
FWIW, I use the "MailToOutlook_2.0.pkg" hosted on https://macadmins.software/tools/, which was built by Paul Bowden from the Microsoft Mac team. It works like a charm to set Outlook to the default email client. I don't think there's one for Excel, but, I've never had to set Excel to the default in my experience. I guess if Apple Numbers is also installed on the Mac that could end up taking precedence for spreadsheet files.
Posted on 08-01-2023 10:38 AM
This is a per-user setting. You have to run each swda command as the logged in user. See the below example.
#!/bin/bash
loggedInUser=$( echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }' )
loggedInUID=$(/usr/bin/id -u "$loggedInUser" 2>/dev/null)
/bin/launchctl asuser "$loggedInUID" /usr/local/bin/swda setHandler --browser --app "/Applications/Google Chrome.app"
exit 0
Posted on 08-03-2023 06:11 AM
Still not working for Excel. Do I have this setup correctly?
#!/bin/bash
loggedInUser=$( echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }' )
loggedInUID=$(/usr/bin/id -u "$loggedInUser" 2>/dev/null)
/bin/launchctl asuser "$loggedInUID" /usr/local/bin/swda setHandler --app '/Applications/Microsoft Excel.app' --UTI 'public.comma-separated-values-text'
exit 0
Script is deployed through a Policy that is assigned Once per user per computer. The policy contains the SWDA binary as a package as well.
Posted on 08-04-2023 07:53 AM
What you have looks correct. I've tested it on my Mac, and it does not work in that case for Excel/CSV. Unless a logout is required which I'm not doing now. 😁
Have you tested the other commands? What version of macOS are you running? Perhaps swda might have stopped functioning.
But my goodness, trying to insert code in Jamf Nation posts in block or inline is just atrocious now.
Posted on 08-04-2023 07:54 AM
And no I'm not a robot, what in the world! 😐
Posted on 08-08-2023 06:46 AM
Ended up using MailToOutlook for Outlook and ran a script on each device to remove Numbers from it - this defaults all CSV files to Excel since there is no other app on the machine. An easy workaround as of right now.