Posted on 08-19-2019 04:48 PM
Trying to run this as the user but im losing my mind:
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/Solar Gradients.heic
I just want to wrap that in a shell and have it use the logged in user to run it. I know I've done this before...but I can't seem to do it right now.
Ive been playing with profiles managing the desktop pic, however this seems to lock it and won't let the user change it which Im not fond of.
Any other solutions would be wonderful if anyone has any.
Gabe Shackney
Princeton Public Schools
Solved! Go to Solution.
Posted on 08-20-2019 07:31 AM
You may want to have a look at the desktoppr tool. Very useful, I deploy it everywhere, much better than dealing with AppleScript intricacies :)
Posted on 08-19-2019 07:30 PM
edit: crap you need the set the desktop instead..
try below script?
i vaguely remember that you need to run sudo killall cfprefsd to apply the changes.
#!/bin/sh
# grab current user
curUser=`ls -l /dev/console | cut -d " " -f 4`
# grab the system's uuid
if [[ `ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-50` != "00000000-0000-1000-8000-" ]]; then
macUUID=`ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-62`
fi
#jamf displayMessage -message $curUser
defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist PrefsVersion -int 100
# Use below to deploy custom screensaver
#defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist moduleDict -dict moduleName "SOMETHING" path "/path/to/file" type -int 1
chown "$curUser" "/Users/$curUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist"
sudo killall cfprefsd
#allow all users access to Folder where the Screensaver is
chmod -R 0777 /path/to/file
Posted on 08-20-2019 04:49 AM
Maybe I can wrap my AppleScript in your shell script though.
Thanks for the fast reply!
Gabe Shackney
Princeton Public Schools
Posted on 08-20-2019 05:07 AM
This should get you what you're looking for.
#!/bin/sh
picLoc="/Path/To/Your/Wallpaper.jpg"
currentUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{print $3}')
#Replace the Current Picture
sudo -u "$currentUser" -H osascript -e "tell application "Finder" to set desktop picture to POSIX file "$picLoc""
Posted on 08-20-2019 05:20 AM
@andrew.nicholas Thanks so much...seems to work perfectly in testing.
Gabe Shackney
Princeton Public Schools
Posted on 08-20-2019 07:31 AM
You may want to have a look at the desktoppr tool. Very useful, I deploy it everywhere, much better than dealing with AppleScript intricacies :)
Posted on 07-21-2021 07:13 AM
@guillaumegete This is actually what we are using now and works perfectly. Thanks!
Posted on 04-13-2022 08:44 AM
We were using this to great result. Now with the removal of python, it no longer works. We are failing with:
Script result: /Library/Application Support/JAMF/tmp/WGU Wallpaper: line 24: /usr/bin/python: No such file or directory
no user logged in, no desktop set