Message screen saver

adamlalicker
New Contributor III

I have a profile set to use Message as the screen saver. Dose anyone know how to set the message for the screen saver via script?
Thanks

1 ACCEPTED SOLUTION

thoule
Valued Contributor II

I just put this together quickly, but haven't tested it. should work... Might need a logout/login before the text is picked up by the screensaver.

#!/bin/sh         
#Todd Houle
#1Sept2016            
ssTEXT="Meat is Murder"

UUID=$(/usr/sbin/system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }')
LocalHomes=$(/usr/bin/dscl . -list /Users NFSHomeDirectory | grep -v /var/ | grep -v /Library/ | awk '$2 ~ /^// {print $2;}')

## FEU                            
for OneHome in $LocalHomes; do
    defaults write $OneHome/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist MESSAGE "$ssTEXT"
    owner=$(ls -l $OneHome/Library/Preferences |grep ByHost|awk '/ByHost/{print $3}')
    chown $owner $OneHome/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist
done

##  FUT
defaults write /System/Library/User Template/English.lproj/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist MESSAGE "$ssTEXT"

## Fix user template
/usr/sbin/chown root /System/Library/User Template/English.lproj/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist
/bin/chmod 700 /System/Library/User Template/English.lproj/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist

View solution in original post

4 REPLIES 4

thoule
Valued Contributor II

I just put this together quickly, but haven't tested it. should work... Might need a logout/login before the text is picked up by the screensaver.

#!/bin/sh         
#Todd Houle
#1Sept2016            
ssTEXT="Meat is Murder"

UUID=$(/usr/sbin/system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }')
LocalHomes=$(/usr/bin/dscl . -list /Users NFSHomeDirectory | grep -v /var/ | grep -v /Library/ | awk '$2 ~ /^// {print $2;}')

## FEU                            
for OneHome in $LocalHomes; do
    defaults write $OneHome/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist MESSAGE "$ssTEXT"
    owner=$(ls -l $OneHome/Library/Preferences |grep ByHost|awk '/ByHost/{print $3}')
    chown $owner $OneHome/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist
done

##  FUT
defaults write /System/Library/User Template/English.lproj/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist MESSAGE "$ssTEXT"

## Fix user template
/usr/sbin/chown root /System/Library/User Template/English.lproj/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist
/bin/chmod 700 /System/Library/User Template/English.lproj/Library/Preferences/ByHost/com.apple.ScreenSaver.Basic.$UUID.plist

adamlalicker
New Contributor III
 

merwyn
New Contributor

The scrip works great. Thank you. To change the settings immediately and not have to powercycle or logout/login, just add the following to the end:

killall cfprefsd

Works great for me.

shrisivakumaran
Contributor

@thoule is it working for Monterey?

Shri Sivakumaran