Aanpassen wallpaper middels Applescript

Pagina: 1
Acties:

  • M-ThijZ
  • Registratie: Maart 2003
  • Laatst online: 11-02 16:11

M-ThijZ

Riding on Rails

Topicstarter
Ik heb een klein script geschreven welke automatisch de laatste wallpaper van interfacelift.com in de juiste resolutie download en middels een stukje Applescript deze wallpaper instelt als achtergrond.

Het Applescript:
code:
1
2
3
4
5
6
7
8
tell application "Finder"
        try
          set image to POSIX file "/path/to/image.jpg" as string
          set desktop picture to file image
        on error
          display dialog "Invalid file /path/to/image.jpg"
        end try
end tell

Dit werkt prima maar het past alleen de wallpaper van het primaire scherm aan, eigenlijk zou ik ook graag deze wallpaper op mijn secundaire scherm weergeven.

Met
code:
1
set desktop picture
wordt de wallpaper van het primaire scherm aangepast, ik ga er dus vanuit dat er ook een equivalent voor het secundaire scherm moet bestaan echter kan ik deze nergens vinden.

  • Red
  • Registratie: Februari 2002
  • Laatst online: 03-02-2023

Red

Blue

Ik meen ergens gelezen te hebben dat het dan desktop2 of secondary desktop was, maar dat weet ik niet zeker, maar je zou het even kunnen proberen natuurlijk....

  • Nitai
  • Registratie: November 1999
  • Laatst online: 11-02 09:46

Nitai

Live the life you love.

Zo werkt ie wel :) Als je er een aliasje van maakt en er een if statement in gooit:

code:
1
2
3
4
5
6
7
8
tell application "Finder" to set maindesktop_pict to POSIX path of (desktop picture as alias)
set the_Plist_file to (path to preferences folder as string) & "com.apple.desktop.plist"
set second_desktop_pict to "/Library/Desktop Pictures/Flow 2.jpg"
tell application "System Events"
   repeat with i in (property list items of property list item "Background" of contents of property list file the_Plist_file)
       tell property list item "ImageFilePath" of i to if value is not maindesktop_pict then set value to second_desktop_pict
   end repeat
end tell

“Believe and act as if it were impossible to fail.” —Charles Kettering


  • M-ThijZ
  • Registratie: Maart 2003
  • Laatst online: 11-02 16:11

M-ThijZ

Riding on Rails

Topicstarter
En aangezien ik dezelfde wallpaper op beide (alle) schermen wil laten zien voldoedt het onderstaande:
code:
1
2
3
4
5
6
7
8
9
    tell application "Finder"
        set desktop_pic to "#{file_path}"
        set desktop_list to (path to preferences folder as string) & "com.apple.desktop.plist"
        tell application "System Events"
            repeat with i in (property list items of property list item "Background" of contents of property list file desktop_list)
                tell property list item "ImageFilePath" of i to set value to desktop_pic
            end repeat
        end tell
    end tell

  • M-ThijZ
  • Registratie: Maart 2003
  • Laatst online: 11-02 16:11

M-ThijZ

Riding on Rails

Topicstarter
Het zou helemaal leuk zijn als ik een overgang zou kunnen gebruiken zoals die in de 'random wallpaper functie' van OS X zit, daarbij zie je de ene wallpaper in de ander overgaan.

Ben helaas bang dat dit geen simpele functie is die vanuit Applescript aan te spreken is.