scriptingosx / desktoppr

Simple command line tool to set the desktop picture on macOS
Apache License 2.0
288 stars 27 forks source link

Feature Request: Add support for scaling keys #3

Closed WardsParadox closed 4 years ago

WardsParadox commented 5 years ago

I think it would be great if desktoppr could also set the scaling keys when setting the desktop.

NSWorkspace has support for the scaling the images: https://developer.apple.com/documentation/appkit/nsworkspace/1527228-setdesktopimageurl https://developer.apple.com/documentation/appkit/nsworkspace/desktopimageoptionkey https://developer.apple.com/documentation/appkit/nsimagescaling

scriptingosx commented 5 years ago

I am not so sure. The System Preferences UI doesn't expose those options any more. Can you describe your particular use case?

WardsParadox commented 5 years ago

10.15 still shows the ability to set the machine to Stretch to Fill Screen, Center, Tile, Fit to Screen and Fill to Screen. Mostly what the keys in the first link I specified. You can also set the background color for the bars in a non-fitting wallpaper via the same gui.

When our machines are first bootstrapped for new staff, the default dock is set. We also set a default wallpaper, I'm currently doing this via pyobjc, but would love to be able to have a tool we can push down for it or for student machines when we do lab setups (combined with a generated wallpaper per machine). Relevant pyobjc code used:

file_url = NSURL.fileURLWithPath_(picture_path)

# make image options dictionary
NSWorkspaceDesktopImageScalingKey = u'NSWorkspaceDesktopImageScalingKey'

options = {}
options[NSWorkspaceDesktopImageScalingKey] = NSImageScaleAxesIndependently
options[NSWorkspaceDesktopImageAllowClippingKey] = True

# get shared workspace
ws = NSWorkspace.sharedWorkspace()

# iterate over all screens
for screen in NSScreen.screens():
    # tell the workspace to set the desktop picture
    (result, error) = ws.setDesktopImageURL_forScreen_options_error_(
        file_url, screen, options, None)

Screen Shot 2019-06-17 at 7 54 31 AM

scriptingosx commented 5 years ago

I have to admit, the main reason I am reluctant is that it would make argument parsing, much harder. But I'd like to have it in there as well. I will think about this.

WardsParadox commented 5 years ago

👍 I might learn me some swift to assist.

scriptingosx commented 4 years ago

implemented in v0.3, please test!

WardsParadox commented 4 years ago

testing today. Color is the hex value only right? No need for a pound/hashtag/number symbol right?

scriptingosx commented 4 years ago

yes, just a six digit hex value

WardsParadox commented 4 years ago

Thought color wasn't working for a bit there, but that was due to the image I was using not working as intended. Seems to work here 👍🏻 Thanks!