0

I found the following script from Change laptop Mac OS X wallpaper upon location but it reads an error when I run it, saying "grep: SSID:: No such file or directory".

set mySSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I|grep \" SSID: \"|cut -c 18-"

if mySSID is equal to "NETWORK_NAME" then
    tell application "Finder"
        set desktop picture to {"Macintosh HD:Users:USER_NAME:Desktop:IMAGE_NAME.jpg"} as alias
    end tell
end if

I'm new to Automator and scripts but want to learn and understand why this isn't working.

Community
  • 1
  • 1

2 Answers2

1

This could be because your wifi is not connected, then the 'cut' function has nothing to cut. better use this syntaxe which just gives you empty string is case no connection, and SSID name when connected:

 set mySSID to do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk '/ SSID: / {print $2}'"
pbell
  • 2,965
  • 1
  • 16
  • 13
  • Awesome, it works! This ends up changing only one desktop though, how would I do it for all of them? – chrisbritish Nov 02 '15 at 05:04
  • sorry, I don't understand your remark. the desktop is changed for the user session. there's only 1 desktop for that session. you have no authorization access to change other users's desktop. or do you mean you want one desktop of each possible SSID ? – pbell Nov 02 '15 at 17:11
  • Sorry, I meant how do I change the desktop for all the Spaces. Currently it only changes the active Space's desktop. – chrisbritish Nov 02 '15 at 18:03
  • I read (but not tested !) that instruction on terminal "kilall dock" will reset all your desktops to get now same picture. I let you test. – pbell Nov 05 '15 at 06:51
0

More clear.

Applescript instructions about space preferences are no longer supported since 10.9.

Also, there is no direct way to set wallpaper on already created spaces. Just for next new spaces, the wallpaper will use same value as space 1.

Work around could be that your script changes the wallpaper in a loop for all existing spaces. In this case, you must define, in system preferences, the keys to switch between spaces, and use keystroke to simulate these keys, then change space and change wallpaper then switch next space and so on. But I have no idea to know how to get the number of spaces currently open !

pbell
  • 2,965
  • 1
  • 16
  • 13