Set Wallpaper on MacOS

This script will set the wallpaper for Mac devices to one of your choosing. Just upload the wallpaper and adjust naming as needed. Please note, if a user has not previously allowed Finder in AppleEvents, they may get a prompt to allow. (If they accidently hit no to allow, AppleEvents can be reset using the command “tccutil reset AppleEvents”)


#copy the .png file to the device
scp DesktopWallpaper.png /library/

#Set wallpaper for user
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{print $3}')
sudo -u "$currentUser" -H osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/library/DesktopWallpaper.png"'
1 Like