Using XCreds Override Script for Dynamic Behavior

You are here:

XCreds provides a preference key called settingsOverrideScriptPath that can be used to make other XCreds settings dynamic. For example, this can be used to set a different background each time a Mac restarts. It can also be used to show updated system info on the login screen in the system info popover. Using settingsOverrideScriptPath is an advanced feature and requires special setup that is described below.

The preference settingsOverrideScriptPath works by allowing a script to be run that can set other XCreds preferences dynamically. This requires special security restrictions to ensure limitations on its use.

Dynamic Background Image Example

Below is an example script and plist file that could be used by settingsOverrideScriptPath. This script would set the preference for loginWindowBackgroundImageURL that is specified in the plist file. The script runs each time the Mac restarts and picks a random background image file from the path specified. It then sets loginWindowBackgroundImageURL to the path for that chosen image.

Script

#!/bin/sh
dir="/System/Library/Desktop Pictures/Solid Colors"
desktoppicture=`/bin/ls -1 "$dir"/*.png | sort --random-sort | head -1
cat /usr/local/xcreds/override.plist|sed "s|DESKTOPPICTUREPATH|${desktoppicture}|g"

Plist

<?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>loginWindowBackgroundImageURL</key>
    <string>file://DESKTOPPICTUREPATH</string>
</dict>
</plist>

File Permissions

For security XCreds requires that proper file permissions be set on the script file. For example, for a script located at /usr/local/bin/override.sh, run the following commands:

sudo chown _securityagent /usr/local/bin/override.sh 
sudo chmod 700 /usr/local/bin/override.sh

The plist file in this example would also need to be placed in /usr/local/bin/ but does not require any file permissions be set.

System Info Popover Example

The following script and plist would show dynamic information on the Lock Screen in the system info popover by setting dynamic info for the preference systemInfoAdditionsArray.

Script

#!/bin/sh
my_special_dynamic_info=`WRITE SOME CODE HERE TO RETURN SYSTEM INFO`

cat /usr/local/xcreds/override.plist|sed "s|SYSTEM_INFO|${my_special_dynamic_info}|g"

Plist

<?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>systemInfoAdditionsArray</key>
    <array>
      <string>SYSTEM_INFO</string>
    </array>
</dict>
</plist>

Connect With Us


Sign Up for XCreds Security and Product Updates

Enter your information below to receive email updates when there is new information specifically regarding this product and how to use it. Alternatively, to receive email updates for general information from Twocanoes Software, please see the Subscribe page.

Name
Tags: