Desktop Background

ewaddy
New Contributor

I have a request from our communications departing requesting that we change our background picture for all domain users. Has anyone successfully done this on either El Capitan or Sierra?

18 REPLIES 18

dmw3
Contributor III

@ewaddy Yes am doing this on both OS.

Download a image file to somewhere on the client computer, then invoke a script to load on login using that image file.

our script below:

# This script changes the Apple Mac OSX wallpaper in 10.10 for the current user
# to Earth Horizon - feel free to set a different JPEG or download, then set it!
# Cribbed from this answer: http://stackoverflow.com/a/2119076
#
# "/Library/Desktop Pictures/Earth Horizon.jpg" (org)
#
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Library/UTAS/utastri.jpeg"'

ewaddy
New Contributor

@dmw3 I get an error when I run the script the error is below

1753aafcd1ea4f6284522dfcd32868b2

Here is the script I ran.

osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/hutower.jpg"'

jamest
New Contributor

You can create a configuration profile to enforce a desktop background picture. I had this in place at one point.

nerutomas
New Contributor

That was my solution in tandem with deploying the .jpg file itself.

I dropped the file inside a folder (this can go pretty much anywhere but best if out of the users reach) then dropped the folder in composer to create a .pkg install.

My policy pops the file in place and a config profile pointing to that file enforces the wallpaper.

You can scope this in many ways, I scoped mine to our loaners so they all say "bring me back, for temporary use only.

carlo_anselmi
Contributor III

Hello, I am resurrecting this old thread... Sorry if it has already been discussed/solved but could not find it...
I have tried using Greg Neagle's desktop_picture.mobileconfig but - despite the profile works perfectly locally (manually installed) - once distributed with JSS I get an empty profile on the clients (10.12.6), please see pictures below. What am I missing? I would rather use a profile limited to the desktop picture instead of the whole "Restrictions" profile in JSS.
Many thanks for your help!!!

288a4906b02041a4a8245f6edbcfa143

sbrennan
New Contributor III

@carlo.anselmi

I packaged the image I wanted as the background to /Library/Desktop Pictures/filename.jpg
created this script to run with the priority after to change the ownership and set the background image.

chown root:wheel /Library/Desktop Pictures/filename.jpg
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/filename.jpg"'

Has worked flawlessly for a year now. Hope this helps.

Shaun

carlo_anselmi
Contributor III

@sbrennan

Hello and many thanks for your message. I tried your script and it works fine but clients can still change their desktop picture once set...
...unless (very likely) I am missing something obvious... only now I am realising I did not mention the goal of preventing users from changing the picture :-)
Anyway, for now I am using Greg Neagle's desktop_picture.mobileconfig distributed manually along with the chosen picture and installed with

Run Unix command '/usr/bin/profiles -IF /private/tmp/desktop_picture.mobileconfig'

If I will ever need to remove it, it only takes distributing the profile itself again and running

Run Unix command '/usr/bin/profiles -R -F /private/tmp/desktop_picture.mobileconfig'

Any smarter solution always welcome!!!
Many thanks again
Carlo

dstranathan
Valued Contributor II

• Is there a way to target multiple displays? I noticed the AppleScript above only sets the wallpaper on the primary monitor when executed on Macs with multiple-monitor configurations.

• Since this script envokes the macOS Finder, can this script be ran on Macs that don't have a console user logged-in at time of execution (i.e sitting idle at the macOS Login Window)?

sbrennan
New Contributor III

@carlo.anselmi I think the best way is to use a configuration profile to lock the desktop background.
You can find that option under the Functionality section when setting up or modifying a configuration profile.

Here is a SS:
42a8acc1877b4ed385145fdbc7357394

@dstranathan We have no macs that require us to set the background for a second display. I will see if I can find something and get back to you.

Shaun

milesleacy
Valued Contributor

Jamf fulfilling this feature request would simplify this issue.

Break Up Multi-MDM-Payload GUI Payloads

carlo_anselmi
Contributor III

Hello everyone, what milesleacy highlights is exactly the reason I decided to use a profile with just one restriction (despite I am not that happy the way I had to manage it...).
Thank you all!

kingrebel
New Contributor

Hello - I was hoping to confirm how a new desktop background can be deployed via jamf into Library/Desktop Pictures/
Im hoping to push a new background some macs, either using a config profile or policy (or both). The user can change this background if they so wish so it doesnt need to be locked down
Has anyone successfully done this and also how?

dsavageED
Contributor III

@kingrebel, If you are looking to put the image files on the Macs disk then either you will need to package them or host them on a web server and download them via script. Deploying the files should be considered a separate process to actually setting the desktop, by the sounds of it you want the desktop picture to be set once per user, likely on login, however this isn't the frequency or scope for how you would ideally deploy the images.

__Uss
New Contributor II

@dstranathan below works for us... shows on all displays.

osascript -e 'tell application "System Events" to set picture of every desktop to ("/Library/Desktop Pictures/Wallpaper.jpg" as POSIX file as alias)'

woodsb
Contributor

Please mark @__Uss 's comment as the correct answer it will save people a lot of time searching the interwebs.

PaulHazelden
Valued Contributor

I have a LaunchAgent that runs at log in. It sets the Desktop Background to the Files I specify. I can also set the two displays to be the same or unique pictures. Yes users can change their picture, but it will reset next time they log in, after a couple of rounds of this I find that they give up.
A couple of things to note. Make the Picture the same size as the Apple ones. Put it in the /Library/DesktopPictures folder. If you try to be tidy and put it in a folder in there it will not resize to fit on the screen.
My script sets the pictures location in bash. And then goes into AppleScript to set the backgrounds. So in the script below $maindisp and $secdisp are the file locations set by the bash script, this allows me to run different pictures based on location of the Mac.

/usr/bin/osascript << EOF
set tlst to {}
set newtop1 to (do shell script "/bin/echo '$maindisp'") as alias
set newtop2 to (do shell script "/bin/echo '$secdisp'") as alias
tell application "System Events"
ignoring application responses
set tlst to a reference to every desktop
set picture of item 1 of tlst to newtop1 -- display 1
set picture of item 2 of tlst to newtop2 -- display 2
end ignoring
end tell

EOF

TJseixas
New Contributor

@__Uss Thank you so much!

arpierson
New Contributor III

I install desktoppr on all of my managed Macs and then set a simple script to run at login calling desktoppr and setting the wallpaper:

/usr/local/bin/desktoppr "/Library/Desktop Pictures/HCBOEwp.jpg"