Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If I set the wallpaper twice in a row with the same image, it removes the wallpaper the second time #68

Open
hisnameisjimmy opened this issue Jul 15, 2020 · 6 comments

Comments

@hisnameisjimmy
Copy link

If I set the wallpaper twice, the second time it will remove the wallpaper and set it to the default desktop wallpaper. The issue is, I can't rely on get to tell me that the wallpaper is correctly set. When the wallpaper is changed back to default, get still returns the wallpaper I set initially. In fact, on MacOS settings, it still shows the correct wallpaper. My program is setting the wallpaper every 24 hours, but it has to be able to reliably recover from a crash, waking from sleep, and timezone shifts. So what I want to do is be able to check if the wallpaper that is currently set is the correct one, and if not, change it. However, because I can't rely on get to do that, I'm not sure what to do.

Am I doing something wrong here? I've tried this on multiple computers and am running into this issue consistently. Maybe there's a good way to work around this limitation?

This is what it looks like if you're running it from the CLI:

// Set the wallpaper
$ /macos-wallpaper set ~/Pictures/wallpaper.jpg --screen all --scale auto
// Wallpaper gets set to this image

// Get the wallpaper
$ /macos-wallpaper get
// Correct image is returned
/wallpaper.jpg

// Run a second set
$ /macos-wallpaper set ~/Pictures/wallpaper.jpg --screen all --scale auto
// Wallpaper now becomes default desktop

// Get the wallpaper again
$ /macos-wallpaper get
// The image I set earlier is returned, even though the desktop is showing the default wallpaper
/wallpaper.jpg

Here's a gif that shows the issue:
CleanShot 2020-07-14 at 18 48 31

@hisnameisjimmy
Copy link
Author

Oddly, if I do this from the CLI, it works just fine.

@sindresorhus
Copy link
Owner

@hisnameisjimmy
Copy link
Author

Super curious why it would work with the CLI, which is ostensibly just accessing this module, but not via the module directly.

Could it be using await that is solving the issue?

@sindresorhus
Copy link
Owner

Could it be using await that is solving the issue?

I assume you're using await too?

@sindresorhus
Copy link
Owner

I, unfortunately, don't have time to look into this, but you might be able to work around it by passing a unique wallpaper path each time. Just copy the image you want to set as wallpaper to a new file with a UUID filename and then pass that path to this package.

@jimmy-nylas
Copy link

Thank you for getting back! The UUID thing is a great idea, I like that workaround. Will report back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants