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

pblake
Contributor III

Did you try using the snapshot method on composer to see what settings are altered? I would imagine it a a bunch of plists. It wouldn't surprise me though if it is a DB in mavericks.

corbinmharris
Contributor

Slightly off-topic, but is there away to manually send out notifications when new items are available in Self Service or to provide reminders of up-coming software push?

mm2270
Legendary Contributor III

@corbin3ci][/url - yes, but it involves using an app like terminal-notifier and a script. Or, if you're on version 9 of the JSS, you may be able to leverage the Management Action.app from a policy. I'm not clear on how easy it is to use the Notification Center feature in 9 just to send out notifications, but it should be possible

Edit: Also, I'm almost certain that these settings for Notification Center are stored in a SQLite db, under both 10.8 and 10.9. They aren't that easy to manipulate or push out as a result.

stevewood
Honored Contributor II
Honored Contributor II

From Item #11 of the "11 Things You Might Not Know About the Casper Suite" presentation at JNUC 2013:

/Library/Application Support/JAMF/bin/Management Action.app/Contents/MacOS/Management Action -title "You win" -subtitle "Thank you #JNUC" -message "That is a wrap"

Of course, you could also use cocoaDialog instead of using Notification Center.

bentoms
Release Candidate Programs Tester

Or even via AppleScript: http://macosxautomation.com/mavericks/notifications/01.html

Which is how I guess JAMFHelper does it.

appleconvert
New Contributor III

@pblake There is a .db in ~/Library/Application Support/NotificationCenter/ I am trying to work out how to setup a policy to deploy it and get the users computer to use it rather than the current .db that is created on the users computer. Any thoughts?

bentoms
Release Candidate Programs Tester

@appleconvert, not sure of the information contained in the below helps at all: https://github.com/alloy/terminal-notifier/issues/44

frank
New Contributor III

I'd also like to change the default from banner to alert also as that way the user has a better chance of seeing the message but also can dismiss it in their own time compared to the 5sec delay currently.

i'm sure there is a way to do a sqlite change for this kinda stuff like it's done for setting the default wallpaper since apple moved away from the .plist for that setting....

nextyoyoma
Contributor

We are wanting to do something similar (I think). We want to disable Messages notifications since we have blocked the messages app, but it doesn't seem that we can set the preference. Anyone had any success with this?

jrserapio
Contributor

Hey guys,

Is there anyway to automate this? Also is there a way to change the size of the window? Management wants the wording not to be truncated on a long message.

Thanks.

bentoms
Release Candidate Programs Tester

@jrserapio, the window is display size is limited by Apple.

For a longer duration & more text I'd suggest looking at JAMFHelper.

jrserapio
Contributor

@bentoms Thanks for the input. I kind of figured that. I just looked into JamfHelper thanks to @stevewood post. I have seen it being mentioned before on other posts, but didn't realize what it could do (visual learner i guess). Now i just have to put JamfHelper to work for me.

Thanks all.

mm2270
Legendary Contributor III

Hi @jserapio - you might also want to take a look at cocoaDialog version 3.x. It specifically has a window type called "notify" that, under version 3 uses an embedded version of Growl to send up small bubble notifications on the screen. In its default behavior the "bubble" window is black with white text, which isn't the nicest look to me, but the advantage is it can accept quite a bit of text without getting cut off. The bubble window expands vertically to whatever size is needed to show the text.
You can also turn off the new Growl like functionality and use the older style bubbles, which lets you specify the exact background, text and border colors to use with hex values, but then you lose the auto window expansion, so its a trade off.

Let me know if you decide to look at that and need some help with it.

ctangora
Contributor III

I filed a request with Apple a few weeks ago to allow admins to control Notification Center through the command line or other means.

ronb
New Contributor II

We did find a way to extend the "Banner" dialog box (see below). You can set the duration it sticks (which by default is approximately 5 seconds) to however long you want. Just a click on it anywhere closes it.

defaults write com.apple.notificationcenterui bannerTime SECONDS
(http://www.cnet.com/news/change-the-notification-center-banner-dwell-time-in-os-x)

The downside, however, is that this is a global setting for ALL banners. So we're still on a hunt to find a way to change the setting from "Banner" to "Alert" - the best solution we believe.

matt4836
Contributor II

In Mavericks and Yosemite, the preferences for Notification Center are stored in a database in /var/folders. You can find the specific database folder for the logged in user with:

getconf DARWIN_USER_DIR

On my computer the database is: /var/folders/8y/0wl97s7x46z279sv8p2h38k80000gn/0/com.apple.notificationcenter/db/db

There is a table called app_info that stores the settings. I wrote a python script that is below that will modify the database. Run with -h to see the help on using it. Run with -i to get specific Bundle IDs.

If you only want to set "Management Actions" to "Alerts" using this script you would upload this script to your JSS and run a policy with the following parameters:

1: -e com.jamfsoftware.Management-Action
2: -a Alert

https://github.com/matt4836/modifyNotificationCenter https://github.com/matt4836/modifyNotificationCenter

jesseshipley
Contributor

@matt4836 how do you get the JSS to pass those parameters into the python script?

matt4836
Contributor II

@jesseshipley
Create new script in JSS
Paste in the contents of this script.
Create policy to run this script. Use the Parameter options. Scope and trigger.

jesseshipley
Contributor

Filling in the parameter options doesn't do anything though. It just makes them accessible variables for $4 and $5 i thought. Wen I run it with those parameters filled it doesn't modify the app I'm trying. If I run the script though passing the variable from the command line it works.

matt4836
Contributor II

@jesseshipley Ah I thought you could pass hyphens through. I will update by the end of the week for Casper. You could always copy it locally first then run another policy that calls it directly with the command lines arguments.

jesseshipley
Contributor

That's what I was planning to do in a worst case. Was just curious if I were missing something about the parameters.

matt4836
Contributor II

@jesseshipley Here is the updated version I tested in 10.9 upgraded from 10.8 (appears that it keeps the database in the home directory). Clean install of 10.9 and 10.10 use the /var/folder.

There are two versions now. One for Casper. Read the first couple lines to use with your policy.

https://github.com/matt4836/modifyNotificationCenter

jesseshipley
Contributor

Thanks for the change! Only thing I notice is that you only have All, Apple, NonApple, and NonSystem now. Is there a way to pass it a specific bundle ID so you are only effecting that one?

matt4836
Contributor II

Yes, you can type in an App Bundle directly. You the first script with -i to get a list. It is possible to modify that script for an Extension Attribute as well, that would return all the notification center bundles for a computer.

Munkeee
New Contributor III

@matt4836 Thank you a ton for building these scripts. Exactly what I wanted. I was using this to set the Management Action prompts to Alerts. With your Casper version, there is one line I think that is missing (I added this to line 204) under the “Figure out what app” section….

elif APPS_IN_QUESTION == "CASPER": cur.execute("SELECT * FROM app_info %s"% APPS_WHERE_DICT["CASPER"])

Every other app variable was listed in the list except the Casper one. As soon as I added this line, the modifications to the Management Action notifications took. Again, thanks for the work on that script!

iweiss
New Contributor III

Thank you @matt4836 for the script and thank you to @bcunning for the correction. The script appeared to do nothing before adding the code for line 204. Now it works like a charm.

tkimpton
Valued Contributor II

doesn't work for me im afraid even after the modifications and putting in the parameters.

error shows t: **Missing or Incorrect Application

ronb
New Contributor II

Matt, All,

I seem to be missing something, probably obvious to someone, but I'm not seeing it - this script worked perfectly for our local casper admin account, but for any other account on the same machine or any other, it did not take. Our user accounts are Active Directory mobile accounts, but I also tested a locally created account, plus another locally created admin account. None of those took the change. Any ideas of what I've missed folks?

I will GLADLY send Matt some cash if I could get this script to work for us!!!!

reelmike
New Contributor II

@ronb , I too am a big fan of @matt4836 's python script... I've been using it for months, worked like a charm in 10.10. But, please correct me if I'm wrong, I believe it is now breaking because the location of the notification database that the script looks for, in "/var/folders/" has either moved, or it is protected by SIP in 10.11.

I haven't had time to test the script on a SIP disabled 10.11 machine, but my hunch is that this is the case.

I'll +1 tho, for the continued development of the script... OR maybe we just up-vote native notification center messages from Self Service itself, here:

https://jamfnation.jamfsoftware.com/featureRequest.html?id=4479

ronb
New Contributor II

@reelmike, I hear ya about finding time. In the mean time, I did vote-up the request you've mentioned!

milesleacy
Valued Contributor

@matt4836 I took a look at your python script as well as some other similar open source projects and found that none of them seem to work any longer (in macOS v10.12.3).

In your research for this script, did you happen to come across a key to decoding the "flags" values found in ~/Library/Preferences/com.apple.ncprefs.plist?

There are some common recurring values such as 14, 22, 86, 535, and 663, with the higher numbers seemingly reserved for Apple applications and system services.

I have had some success with delivering settings via custom payloads in configuration profiles, but I'd like to fully understand the potential values of the flags key.

02c58e6caa2e4c4ea1d446df36a1f172

myronjoffe
Contributor III

Hey @milesleacy interested in your experiences with managing notifications with custom config profile. Not having any luck with disabling outlook notifications at lock screen with below as user or device profile... Seems like outlook like changes from 14 to 4110 when checking the option to not allow at lock screen...

<?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.microsoft.Outlook</string>
            <key>flags</key>
            <integer>4110</integer>
        </dict>
    </array>
    <key>sort_order</key>
    <integer>0</integer>
</dict>
</plist>

matt4836
Contributor II

@milesleacy It was a bit-shifting. If I recall 14 was the default value. 14 as binary, 000001110. By changing values from 0 to 1 turns on different preferences. Look at my script to see the values. 1 << 5 would turn on the fifth bit. Hope that helps.

ClassicII
Contributor III

Did anyone figure out how to change Jamf Management Notifications to "Alerts" for 10.12 and up?

milesleacy
Valued Contributor

bdca150e13a543c3a63557f65670c7b8
@ClassicII

This seems to work. I'd prefer some sort of documentation as to why and how, but this profile keeps my Jamf notifications set to alert (in an "MCX-often" way - that is, the user can change it, but it gets reset at the next login, even though it's a computer level profile).

This feature request is tangentially related... https://www.jamf.com/jamf-nation/feature-requests/6276/provide-full-notification-center-functonality

ClassicII
Contributor III

@milesleacy

Thank you very much for posting that!

I agree that it would be great to see some real documentation on this.

Speaking I see you changed the logo!!! how did you do that ?

milesleacy
Valued Contributor

@ClassicII If you're referring to the notification icon below, that's my own compiled instance of yo.app, with a company icon swapped into the Xcode project before compiling.

https://github.com/sheagcraig/yo

dd38d878eb4e47a7a61254e9bd1e2851

milesleacy
Valued Contributor

@ClassicII

If you decide to use Yo, you can achieve the same thing we've been discussing here re: notification center alerts with your Yo app via its bundle identifier (which you can customize in the Xcode project).

UID501
New Contributor

Does anyone know how we could simply append the com.apple.ncprefs preference file that is already there with the information described by milesleacy? When I create a config profile and just upload a .plist with the custom settings, as I suspected, it overwrites the file already there on my test machine. This would change users settings for other app notifications which is obviously not desirable. I simply want to append the file with the text below. Any ideas on how to do this successfully with Jamf? Thanks!
446ab22769124e3c8e3d89b63662ef6c