Change notification center alert duration

appleconvert
New Contributor III

Does anyone know how to successfully change then capture the changes made to the Notifications pane in System Preferences so I can then push the settings to end users?

I would like to change the Management Action from Banners to Alerts so the notifications I push to the users have to be manually dismissed by the user. Currently with the banner alerts users only have a couple of seconds to read the alert unless they open up notification center which they don't generally use.

external image link

Many thanks in advance.

46 REPLIES 46

jesseshipley
Contributor

@UID501 so I'm heading down this rabbit hole myself and much as I love profiles, I saw the same issue with the custom profile. Beyond that, to get the results to actually appear you need to reload NotificationCenter and usernoted, so you lose the instantaneousness that makes profiles great. I just threw this together as a way of just changing the com.jamfsoftware entries in the preference an kicking the needed processes. It seems to work, but please dest yourself as I literally just had it work once on my machine so far.

#!/bin/sh
CURRENT_USER=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");')

plutil -convert xml1 /Users/$CURRENT_USER/Library/Preferences/com.apple.ncprefs.plist

COUNT=0
TOTAL=$(/usr/libexec/PlistBuddy -c "Print :apps" /Users/$CURRENT_USER/Library/Preferences/com.apple.ncprefs.plist | grep "Dict" | wc -l)

while [ $COUNT -lt $TOTAL ]; do
    if [[ $(/usr/libexec/PlistBuddy -c "Print :apps:$COUNT:bundle-id" /Users/$CURRENT_USER/Library/Preferences/com.apple.ncprefs.plist) == *"com.jamfsoftware."* ]]; then
        /usr/libexec/PlistBuddy -c "SET :apps:$COUNT:flags 86" /Users/$CURRENT_USER/Library/Preferences/com.apple.ncprefs.plist
    fi
    COUNT=$((COUNT+1))
done

plutil -convert binary1 /Users/$CURRENT_USER/Library/Preferences/com.apple.ncprefs.plist

killall sighup usernoted NotificationCenter

Also please vote on my feature request as it is silly that we have to do this. https://www.jamf.com/jamf-nation/feature-requests/6910/self-service-push-notifications-should-be-configurable-as-alerts-instead-of-user-default-badges

milesleacy
Valued Contributor

@UID501

You'd have to customize the profile further than capturing a local com.apple.ncprefs.plist file and uploading it to a custom payload in Jamf Pro.

To manage only the setting(s) you're interested in, you would have to make a copy of the file and delete all superfluous items before uploading. In the case of configuring the Jamf Management Action application, that source file for the custom payload would look like this...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>bundle-id</key>
    <string>com.jamfsoftware.Management-Action</string>
    <key>flags</key>
    <integer>86</integer>
</dict>
</plist>

Note: If you wanted to set this for both Management Action.app and Self Service.app, I would recommend two separate profiles. Modulatity is key. You, your management, or your users may come up with reasons to change one setting and not the other, in which case, it is cleaner, easier, and less disruptive if the settings are in separate profiles.

milesleacy
Valued Contributor

@UID501

You'd have to customize the profile further than capturing a local com.apple.ncprefs.plist file and uploading it to a custom payload in Jamf Pro.

To manage only the setting(s) you're interested in, you would have to make a copy of the file and delete all superfluous items before uploading. In the case of configuring the Jamf Management Action application, that source file for the custom payload would look like this...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>bundle-id</key>
    <string>com.jamfsoftware.Management-Action</string>
    <key>flags</key>
    <integer>86</integer>
</dict>
</plist>

Note: If you wanted to set this for both Management Action.app and Self Service.app, I would recommend two separate profiles. Modularity is key. You, your management, or your users may come up with reasons to change one setting and not the other, in which case, it is cleaner, easier, and less disruptive if the settings are in separate profiles.

jesseshipley
Contributor

@milesleacy sadly, pushing any profile for ncprefs, even with just the apps like you have written above, will cause all the apps to go back to their default settings (obviously not including whatever you mandated in your profile.) Every time the users logs in, their prefs will be blasted back to default as it reloads ncprefs. I do not know why this is.

PatrickD
Contributor II

Hi @milesleacy,

I have tried your plist as well as creating my own and deploying through Custom Settings in a Config Profile but the Notifications preferences on the client machine didn't change at all.

I have tested this with both 10.13.4 and 10.12.6 machines.

Are you, or is anyone else, able to confirm if this is working?

-Pat

milesleacy
Valued Contributor

@jesseshipley hmm. I hadn't noticed this behavior. I'll test for it, although it does kind of make sense.

Another point to investigate would be if the keys can be managed in the "com.apple.ncprefs.managed" domain. I'm not sure if this domain exists, but it stands to reason that it might, given Apple's MDM & preference conventions.

@PatrickD I have had consistent success on 10.11 and later, possibly with the caveat that @jesseshipley mentioned.

violetbloom
New Contributor

You have to make sure to include the extra dict & apps array. Also, you need to kill the notification center to see it right away.

killall sighup usernoted NotificationCenter

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>apps</key>
   <array>
      <dict>
         <key>bundle-id</key>
         <string>com.jamfsoftware.Management-Action</string>
         <key>flags</key>
         <integer>86</integer>
      </dict>
   </array>
</dict>
</plist>