1

So, I have this name.sh script with bunch of shell commands. I need to change the wallpaper before ending that script.

I'm using

osascript -e 'tell application "System Events.app" to set picture of every desktop to "/Library/Desktop Pictures/my.jpg"'

at the end of the line. The thing is the Apple Script won't run under root. Because System Events will throw 10810 at first and then 600 (Application isn't running). If I run this osascript under admin user, it will work just fine. The wallpaper will be set.

Let me know how you guys can help me in this!

Stefan Becker
  • 5,695
  • 9
  • 20
  • 30
Kamesh S S
  • 15
  • 4

1 Answers1

1

If you are already root, you have full privileges to switch to a different user account at any time. The command for that is su.

If your user is admin,

su - admin <<\:
    osascript -e 'tell application "System Events.app" to set picture of every desktop to "/Library/Desktop Pictures/dneg.jpg"'
:

There are various ways to pass the command as standard input to su; perhaps see also Pass commands as input to another command (su, ssh, sh, etc)

tripleee
  • 175,061
  • 34
  • 275
  • 318