You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bart Reardon edited this page May 23, 2024
·
10 revisions
Instead of using numerous command line options for construction complex dialogs, you can use the --jsonfile or --jsonstring options to define parameters.
The JSON format uses the same options as specified on the command line with a few exceptions and considerations.
Note:
Command line options can be used in conjunction with JSON but any options defined in JSON will take precedence.
To support literal \n characters in the message text, --jsonstring will expect JSON input to be on one continuous line
Most options will be passed through as string values requiring quotes for the specified values. Some values can be specified as a boolean value though (true or false, without quotes). Options that take a boolean value are:
There are a number of options that are not available to be used from JSON as they do not make sense in a deployed context. They are:
--jh - used as a drop in replacement to accept JamfHelper command line options.
--listfonts - used during prototyping to display a list of fonts available
--help - displays help text and exits. Used during prototyping
--demo - displays a dialog using nothing but the default settings. Used during prototyping
--version - outputs dialog version info and exits.
--showlicense - prints license info and exits
--coffee - prints coffee info and exits
Example: generating json in python and passing in as a file or a string
#!/usr/bin/python3importjsonimportos# set to false to generate an intermediate json file# set to true to pass generated json in as a stringstringinput=Truedialog_app="/Library/Application Support/Dialog/Dialog.app/Contents/MacOS/Dialog"contentDict= {"title" : "An Important Message",
"titlefont" : "name=Chalkboard,colour=#3FD0a2,size=40",
"message" : "This is a **very important** messsage and you _should_ read it carefully\n\nThis is on a new line",
"icon" : "/Applications/Safari.app",
"hideicon" : false,
"infobutton" : true,
"quitoninfo" : true
}
jsonString=json.dumps(contentDict)
ifstringinput:
print("Using string Input")
os.system("'{}' --jsonstring '{}'".format(dialog_app, jsonString))
else:
print("Using file Input")
# create a temporary filejsonTMPFile="/tmp/dialog.json"f=open(jsonTMPFile, "w")
f.write(jsonString)
f.close()
os.system("'{}' --jsonfile {}".format(dialog_app, jsonTMPFile))
# clean upos.remove(jsonTMPFile)