Running as cronjob
p3k opened this issue · comments
Any hints how this could run as a cronjob?
I tried it with the following lines in my user crontab – the image is downloaded but not set as the desktop wallpaper:
#!/bin/bash
sessionfile=`find "${HOME}/.dbus/session-bus/" -type f`
export `grep "DBUS_SESSION_BUS_ADDRESS" "${sessionfile}" | sed '/^#/d'`
himawari-bg
Any ideas?
(Running himarawi-bg
directly in a shell on Ubuntu 15.10 works great btw.)
Why not http://merencia.com/node-cron/ ?
Hm. Why would I need another cron implementation next to an already existing one…?
Would it work with node-cron, though?
Because the wallpaper isn't being set with the default from implementation? Just a thought, I was reading about this library yesterday so I thought I'd share.
In fact, it'd be great to include this and have the scheduler be part of the API!
I don't know why it wouldn't set the BG though and I also don't know if node cron would solve this
I hardly see the benefit. Besides node-cron not supporting e.g. @reboot
(which is what I actually want) it seems I would have to run a node script on startup which runs node-cron which in turn runs himawari-bg… No?
So it seems like the issue primarily lays with the wallpaper module?
Been wanting to investigate this, currently backing up and reformatting my hard drive due to a critical system failure. If I don't end up needing to buy a new laptop I'll try to come up with a good solution this weekend.
It works fine for me, but I had to export my PATH variable again.
This is the script that I currently. It's being trigger by cron every 10minutes:
#!/bin/bash
export PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin;
himawari-bg --outfile /Users/Xavier/Pictures/himawari-images/latest.png
I made a menubar app that accomplishes the same thing here: https://github.com/ungoldman/hi8
@ungoldman I saw your application and it works really well. However, I don't want to run a full instance of Electron (with Chrome and V8) for just changing my wallpaper. I don't want to consume all that RAM all the time.
So this tool was perfect for me. It only runs every 10minutes and is pretty lightweight. ;)
@Savjee that is a fair point! However I will say hi8
never opens an electron BrowserWindow
instance, so the memory footprint is not as bad as it could be (quite a lot less than an electron app like slack or atom). Still perhaps more than one could reasonably justify using for changing a wallpaper.
I faced the same issue than you, @p3k, and edited my cron as such:
$ crontab -l
*/10 * * * * /usr/local/bin/himawaripy && /usr/bin/gsettings set org.mate.background picture-filename `ls -rt ~/.cache/himawaripy/*.png| tail -1`
Hello from four years in the future 👋
Thanks all for the discussion. I'm closing this since it's not an issue with the library so much as with crontab and OS/env configuration.
I will say I just tried setting a new crontab on latest macOS roughly like so...
0/15 * * * * /Users/me/cron_scripts/himawari.sh &> /Users/me/cron_scripts/himawari.log
#!/bin/bash
# add homebrew to path for imagemagick, etc
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
# add npx to path using wacky nvm script
# note: this script prepends PATH with node/npm/npx paths,
# which MUST precede homebrew b/c it may have its own node copy
/Users/me/.nvm/nvm.sh
npx -y himawari-bg
...and it worked as expected.
The biggest stumbling block is definitely making sure the PATH
is correctly set up, as crontab's execution context is independent from any bash profile stuff you might otherwise have set up (at least in macOS, to my knowledge).
I just updated himawari-bg to get it back in working shape and added a couple of new options (screen
& scale
).
Happy Monday from -8 UTC