Skip to main content

Does anyone know if there is a way to do this in Yosemite? I ran opensnoop while changing preferences to see if I could figure out where it saves them to but didn't see anything being modified.



I'd like to programmatically disable notifications at the lock screen for all items for all of our users. In Mavericks I had disabled Notification center. Being that JAMF moved their agent notifications to using it we no longer see those:-(. Hoping Yosemite is a little more configurable.

NCutil.py can't change that setting quite yet, but it can do a lot. Special thanks for @gregneagle for all his contributions!



Add apps



NCutil.py -i com.noodlesoft.HazelHelper
NCutil.py --insert com.noodlesoft.HazelHelper


Remove apps



NCutil.py -r com.barebones.textwrangler
NCutil.py --remove com.barebones.textwrangler


Adjust Alert Duration (Alerts, Banners, or None)



NCutil.py -a com.apple.Safari alerts
NCutil.py -a com.apple.reminders banners
NCutil.py --alert-style com.apple.appstore none


Get Current Settings
You can find out what the app's current settings are:



NCutil.py --get-info com.teamviewer.TeamViewer


which will return something like this:



Notification Center settings for TeamViewer.app:
TeamViewer.app alert style: Banners
Show notifications on lock screen: Yes
Show in Notification Center: 5 Recent Items
Badge app icon: Yes
Play sound for notifications: Yes


Get Current Alert Setting



NCutil.py -g com.teamviewer.TeamViewer
NCutil.py --get-alert-style com.teamviewer.TeamViewer

nice work @jacob_salmela ! I put a feature request in with Apple to do this kind of stuff recently. This is great for the meanwhile though, will try it out thanks!


@Dickson : @gregneagle 's most recent addition now allows you to change the settings you want. Here are a few examples:



Show iCal Notifications on the lock screen



NCutil.py --show-on-lock-screen true com.apple.iCal


Disable the badge app icon for Messages



NCutil.py --badge-app-icon false com.apple.iChat


Disable the sound for TextWrangler



NCutil.py --sound false com.barebones.textwrangler


Set the amount of recent Notifications to show to 20 for Dropbox



NCutil.py --show-in-notification-center 20 com.getdropbox.dropbox

Wow. Thanks @gregneagle and Jacob! Is there a way to list the current apps so I can script a loop to apply the settings to all?


NCutil.py -l


but be cautious of the SYSTEM_CENTER items.


Perfect. You guys rock!


In order to run this file through a script (at a Policy ) , we have to do something different or just : python NCutil.py --show-on-lock-screen true com.apple.iCal ???


This is awesome. Any thoughts on how to adjust the default notifications on lock screen. Notification Center defaults all apps to show notifications on lock and I would like to change that if possible.


I'm getting error messages when I try this. I'm trying to disable the lock screen notification for Jabber, and I created a script with the following:



python /Library/Company/NCUtil.py --show-on-lock-screen false com.cisco.Jabber


created a policy to run that script, and it gives error messages:



Executing Policy Change Jabber Lock Screen Notification
Running script Change Jabber Lock Screen Notification...
Script exit code: 1
Script result: Traceback (most recent call last):
File "/Library/Company/NCUtil.py", line 605, in
main()
File "/Library/Company/NCUtil.py", line 595, in main
options.show_on_lock_screen[0], options.show_on_lock_screen[1:])
File "/Library/Company/NCUtil.py", line 401, in set_show_on_lock_screen
if not bundleid_exists(bundle_id):
File "/Library/Company/NCUtil.py", line 153, in bundleid_exists
conn, curs = connect_to_db()
File "/Library/Company/NCUtil.py", line 69, in connect_to_db
conn = sqlite3.connect(nc_db)
sqlite3.OperationalError: unable to open database file

Error running script: return code was 1.


It worked on one machine that I had logged in, but on all other test machines with me logged in or other employees, it failed with the above errors. Any ideas?


Hey, Mark.



Did you ever get this to work? I'm having the exact same issue when calling this script from a Casper Policy.



Thanks!


Okay, I figured out that the problem is that JSS scripts are run as a different user and therefore it doesn't have permission to open the db for the current user… Or the other way around. Thing is, if I try to run this remotely, it fails.


@bearzooka
@Mark.Stohel



#!/bin/sh


IFS=$'
'
user=`ls -l /dev/console | cut -d " " -f 4`

a=`sudo -u $user /usr/local/bin/NCutil.py -l | grep -v "SYSTEM_CENTER"`
for i in $a;
do
#echo "User:Disabling show on lockscreen notify for: $i"
sudo -u $user /usr/local/bin/NCutil.py --show-on-lock-screen false $i
done

Thanks, @MrP.
I did something similar but using the $4 parameter.


@jacob_salmela, @gregneagle In the script I modified the following line which allowed it to run on 10.12, however the option "--show-on-lock-screen" has no affect. Any chance you can updated it for 10.12?



elif osx_major == '10.10' or osx_major == '10.11':


to:



elif osx_major == '10.10' or osx_major == '10.11' or osx_major == "10.12":

I'm a bit busy with other projects at the moment, but if someone makes me a pull request, I can review it. I'm guessing Apple changed something slightly in their DB structure. They did a similar thing with TCC.db.


Has anyone used this successfully on 10.11.6 (15G1217)?



I get the following output...



bash-3.2# /.../.../.../NCutil.py -l
Traceback (most recent call last):
File "/.../.../.../NCutil.py", line 605, in <module>
main()
File "/.../.../.../NCutil.py", line 572, in main
list_clients()
File "/.../.../.../NCutil.py", line 99, in list_clients
conn, curs = connect_to_db()
File "/.../.../.../NCutil.py", line 69, in connect_to_db
conn = sqlite3.connect(nc_db)
sqlite3.OperationalError: unable to open database file


bash-3.2# /.../.../.../NCutil.py -a com.jamfsoftware.Management-Action alerts
Alert style must be one of: none, alerts, banners.


EDIT: Same results with 10.10.5 (14F2109)


Note...



There is a Notifications payload in the Apple Configurator 2 application (pictured). A profile that contains this payload can be applied to a Mac running macOS Sierra (applying the profile to El Capitan or Yosemite yields no results). The result is similar to an MCX setting applied at the user level with an "often" frequency, that is the setting applies at every login, but can be changed during the user's session.



I am making the assumption that this is new behavior that is making its way into macOS (yes, I know I could be wrong) and as such using it.



Since Yosemite and El Capitan are relatively static at this point and will be supported for roughly another six months and year and a half, respectively, and this solution had worked in those OS versions before, I was hoping to use the script on my Yosemite & El Capitan Macs.



My goal here is to find a way to set notifications from the Jamf Management Action application to use the "alerts" alert style because they are persistent until interacted with - thus users have less room to claim they didn't know about a change.




@milesleacy Did you get this to work using profiles?


@milesleacy Did you get this to work using profiles?


@myronjoffe Yes, through trial and error, capturing manually-set values in plists, and then adding those values to a custom payload.


Revisiting this topic, but now for High Sierra… The Notifications db structure seems to have changed dramatically and I haven't been able to find a table with the Flags column or something similar. Maybe @jacob_salmela has some pointers on how to find that info again.



Also, I've tried using Apple Configurator 2, as @milesleacy suggests, and every Config Profile I try to install marks the payload (i.e. Notifications settings) as being iOS only and does pretty much nothing.



Thanks for your input!


Has anyone here look at Yo? It does notification style dialog boxes


Hi @jacob_salmela any option to disable "show notifications on lock screen" in Sierra?


Sorry; it's been a while since I've worked on the project...I'll take a look and get back to you


Hey, @milesleacy. I've been trying to hide the notifications in the lock screen using a Config Profile and haven't had any luck. Do you have by any chance an example plist that you've used as a custom payload?



Whatever I try keeps installing empty MCX config profiles that obviously don't work as expected.



Thanks in advance.


Reply