Posted on 06-15-2017 07:36 PM
Hi,
What would be the best way to set a wallpaper but allow the user to change it, I already have a config profile to enforce wallpapers on shared machines, but for our 1:1 machines I want to set a default wallpaper but allow the user to change it afterwards
Posted on 06-16-2017 06:47 AM
This discussion should shed some light on how to do it. If you want it to also apply to the current logged in user you can add something like this:
#!/bin/bash
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 "/path/to/file/name.jpg"'.
Posted on 06-19-2017 02:16 PM
I found the easiest way to set the default desktop image to a branded custom image was to name it Sierra.jpg and change the name of the Sierra.jpg to Sierra 3.jpg.
The package we deploy:
Posted on 06-20-2017 09:52 AM
I found that using this approach works before for me. It points to a folder in which we deploy our assets too. This also allows users to change their background as well.
osascript -e 'tell application "System Events" to set picture of every desktop to ("/Library/XXXX/XXXX.jpg" as POSIX file as alias)'
Posted on 06-22-2017 09:40 PM
Thanks. I only wanted to make this policy apply to newly enrolled devices so I made a smart group called "New Enrollments" and the criteria for this group is "Enrollment less than 1 day ago" and Scoped the policy only to this smart group
Posted on 11-13-2017 09:40 AM
Hey @Echevarria,
I was hoping you might be able to help us out with this process. I don't know if you remember but you actually did our Jumpstart. We had a .pkg coupled with a script to replace the Sierra.jpg and rename the old file and then to subsequently set that wallpaper as the default on all users. However, we're running into some issues.
Are you able to go through it with me to detail how we can replace the default wallpaper with a .jpg of our choosing? Thanks in advance!
Ross
Posted on 11-14-2017 10:25 AM
Here's what we do.
Deploy pictures to the
/Library/Desktop Pictures
Folder
Then we run this script.
#!/bin/bash
# $3 is the logged in user - default for most policies.
sudo -u $3 /usr/bin/osascript <<ENDofOSAscript
tell Application "Finder"
set the desktop picture to {"Library:Desktop Pictures:<jpgofpicturehere>.jpg"} as alias
end tell
ENDofOSAscript
exit 0
Posted on 11-20-2017 11:45 AM
@rderewianko Thanks for that script. As a test, I manually placed a .jpg in that folder and then ran the script but didn't see anything occur - should I have? If I'm currently logged in as a user and then run that script, would I see the wallpaper change or can I not be logged in to see it take effect? I was testing it on a computer with Deep Freeze so I couldn't restart, but I can run it on another computer. Thanks for your help!
Ross
Posted on 11-20-2017 11:51 AM
When you ran the script did you edit it to the file you put on the machine? the line <jpgofpicturehere>.jpg needs to reflect the file name.
Posted on 11-29-2017 03:08 PM
@rderewianko Thank you for the script!!! Worked like a charm and was a fun alternative to setting the macOS Desktop Background using a Configuration Profile.
As an alternative for maybe a lab computer try this!
Workflow:
Configuration Profile: Install Automatically --> Computer Level
Restrictions Payload: Functionality Tab --> Lock Desktop Picture --> /Library/Desktop Pictures/Thor.jpg (or whatever JPG/file path)
Scope --> All Computers or specific groups
Save and watch the magic!
Configuration Profiles are SWIFT and unforgiving or to quote a good friend of mine... Persistent and authoritative.
Posted on 01-25-2018 09:44 AM
Is there any way to modify this to apply a wallpaper to ALL connected displays @rderewianko ?
We have a client that wants them applied to all connected displays on Macs and PC's.
TIA
The base script works great - Thank you.
Posted on 01-26-2018 09:44 AM
I've been looking for a way a long time now, which would work smoothly in any situation.
I did change the wallpaper on my machine and did make a "Desktop Pattern" snapshot with Jamf Composer.
In addition to that, I did also include the wallpaper into the same "Desktop Pattern" and since it is in the user folder, I did create a dmg file.
Uploaded it via Jamf Admin, published it with "FUT" and "FEU".
After installing the Desktop Pattern DMG, I simply kill the dock "killall Dock" and that's it.
P.s. If you'd like to change the lock screen as well, please set a script before, which removes the cache file "rm -rf /Library/Caches/com.apple.desktop.admin.png "
Hope this helps
Posted on 09-13-2018 12:37 PM
Anybody tried this on Mojave where osascript causes a message like
xxx would like to control the application “Finder”
to appear?
Posted on 09-13-2018 12:46 PM
In System Preferences -> Security & Privacy -> Accessibility "Allow the apps below to control your computer"
The applescript app has to be there in order to avoid the dialog, this was a fix in 10.13 & up.... i believe a lot of people have ran into this problem.
The problem lies in the tcc.db and not being able to write sql too it anymore....i am not aware of an easy workaround..i've been scouring the internet for it as well.. I hope this helps! (Forgive me if this is innaccurate information as we have not yet moved from High Sierra to Mojave in my organization, so my knowledge is limited to 10.13)
here are some other discussions for reference
https://www.jamf.com/jamf-nation/discussions/24910/programmatically-set-accessibility-for-an-app-in-security-and-privacy
https://www.jamf.com/jamf-nation/discussions/29295/allowing-security-privacy-privacy-accessibility-allow-the-apps-below-to-control-your-computer
Posted on 09-13-2018 12:48 PM
Does this script get around the TCC/Mojave prompt?
https://github.com/grahamgilbert/macscripts/blob/master/set_desktops/set_desktops.py
Posted on 09-13-2018 12:48 PM
The question is how do I get the app (which is a shell script running in terminal launched during the initial enrollment) in there to make the wallpaper actually appear after enrollment? I don't want to force a specific wallpaper, just set the initial one that the user can change.
Posted on 09-13-2018 12:53 PM
for our enrollment process I created a package with a new wallpaper named "High Sierra.jpg" that is placed in the Desktop Picture directory and overwrites the apple default wallpaper
Location "/Library/Desktop Pictures/High Sierra.jpg"
you can always rename the Default to a new name and save it as well in the event a user likes the default but this way you get your institutions wallpaper by default and no need for a config profile to lock it down and the user can then change the wallpaper.
Posted on 10-11-2018 12:19 PM
@Hugonaut did you just do a Composer snapshot for this or was it a package with the image as the payload and a script to perform the copy?
Posted on 10-11-2018 12:25 PM
@vmascoli For our Mojave Prestage I used composer and packaged it, deploys during prestage enrollment so it is there once you login.
a method I have also used features oasascript deployed by jamf for putting in place forced profiles but it all works the same you can just path the script on the fly of course. this is if you have a webserver setup though.
#!/usr/bin/osascript
set UNAME to "username"
set PASSW to "password"
try
do shell script "mkdir /Library/DirectoryHere/" user name UNAME password PASSW with administrator privileges
end try
try
do shell script "curl -o /Library/DirectoryHere/WallpaperHere.jpg http://server.com/wallpapers/Wallpaper.jpg" user name UNAME password PASSW with administrator privileges
end try
Posted on 10-11-2018 12:37 PM
Just thought I'd add what I just setup today (and tested it on High Sierra 10.13.6), using various bits I found on Jamf Nation if someone else can use it. I couldn't get it to reliably work with the other scripts I saw. Oh well.
Created a Policy that has:
The package created with Snapshot like what @stevevalle did above.
The script from @andrew.nicholas (repeated below) to force the the desktop image to change. (Not sure if it works on multiple displays...I hope it does, but its not the end of the world.)
#!/bin/bash
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/Desktop Pictures/High Sierra.jpg"'
#!/bin/sh
rm -rf /Library/Caches/com.apple.desktop.admin.png
Posted on 10-11-2018 12:38 PM
@Hugonaut So it's placed in the Attachments section and gets run by being part of the Prestage?
Posted on 10-11-2018 12:45 PM
Use this
https://github.com/scriptingosx/desktoppr
It’s great and does not use AppleScript so no problems with PPPC.
Also can control multi screens
Posted on 08-23-2019 09:38 AM
Great stuff. But, how do I center the image on the desktop and pad it with a crayon specific color?
Posted on 07-15-2020 01:39 PM
@Lotusshaney are you doing anything specific for Mojave/Catalina? We use DEPnotify for our deployments and as part of it we install wallpapers to the default folder and set them via $ desktoppr "/Library/Desktop Pictures/specific background.jpg". It flashes for a second then goes back.
Posted on 06-09-2021 06:57 AM
@rpayne I was able to get desktoppr working on M1 Big Sur devices. I used this postinstall script from the desktoppr github as a guide: https://github.com/scriptingosx/desktoppr/blob/master/examples/postinstall
The basic method recommended in that script is sudo -u "$loggedInUser" launchctl asuser "$uid" "$desktoppr" "$picturepath"
, but the sudo -u "$loggedInUser"
piece doesn't appear to work on Big Sur; dropping the sudo piece and running launchctl asuser `id -u $3` $desktoppr "/path/to/desktop-background.png"
in a script payload does. It throws a warning, "desktoppr is running as root. This is probably not what you are intending. To set the desktop picture for a user, desktoppr needs to run as that user." but it works nevertheless.