NITDgpOS / UIP

A library, to customize your desktop wallpapers.
https://nitdgpos.github.io/projects/UIP
GNU Affero General Public License v3.0
19 stars 45 forks source link

macOS: Set wallpaper not working #326

Closed nkprince007 closed 7 years ago

nkprince007 commented 7 years ago

Bug report: http://pastebin.com/ftCYW3r9

Probable cause: Updated osascript / Outdated requirements.

nkprince007 commented 7 years ago

Cause identified: System Events application located at /System/Library/CoreServices/System Events.app might not be running sometimes.

nemani commented 7 years ago

How do we start it?

nkprince007 commented 7 years ago

Maybe we need to change our requirements. py-appscript looks promising. Since, AppleScript comes with macOS and the cited package is just a wrapper to NSAppleScript originally written in Objective-C. If we proceed this way, we would need to write an AppleScript to get our job done via System Events, inherently invoking the cited process, if it isn't already running.

nkprince007 commented 7 years ago

Set wallpaper:

tell application "System Events"
    set picture of every desktop to "/Library/Desktop Pictures/Abstract.jpg"
end tell

Get Wallpaper:

tell application "System Events"
    get picture of every desktop
end tell

This applescript always seems to work. I even tried it by deliberately killing System Events.app. :heart: AppleScript, it's quite so readable. Makes things a lot easier. I think we could just dump even the use of any requirements for OSX. The AppleScript could even be invoked even from command line via osascript tool.

nkprince007 commented 7 years ago

@abhsag24 @nemaniarjun Need your opinions on this one. I prefer to use the osascript tool via subprocess and Popen rather than adding appscipt or py-appscript as a dependency.

nemani commented 7 years ago

I agree, If we can remove dependencies AND improve functionality, then why not? :+1: