sindresorhus / wallpaper

Manage the desktop wallpaper
MIT License
1.05k stars 92 forks source link

Problems setting wallpaper from cron or as sudo #57

Open MDabrowski9LD opened 5 years ago

MDabrowski9LD commented 5 years ago

When invoking simple script that should change wallpaper with sudo ie: sudo /abs/path/script.js or from cron * * * * * /abs/path/script.js wallpaper stays the same. When called manually and without sudo/cron it works as intended.

Any ideas what might be wrong?

sindresorhus commented 5 years ago

What OS, version, and Node.js version?

MikeDabrowski commented 5 years ago

Linux mint 18 (cinnamon and sonya i think), node 11.10.1. Wallpaper installed globally, NODE_PATH pointing to node_modules where it is installed. I use absolute path to image. Added #! /usr/bin/node to the script and calling it only by name.

MDabrowski9LD commented 5 years ago

I think I got it. Cron has limited env and in order to set wallpaper some env variables have to be exported. I found this https://askubuntu.com/a/198508 post and adapted to my case. It worked.

sindresorhus commented 5 years ago

Would you be willing to submit a PR to the readme with a tip about the above? I'm thinking a new Tips section at the bottom.

MikeDabrowski commented 5 years ago

Sure, how about I put my solution for daily wallpaper changer in examples folder ?