Closed nmiculinic closed 3 years ago
The script optionally accepts an external config file at ~/.config/sunpaper/config ... is that sufficient for your needs?
I'm pretty new to bash but will look into and test the script in "strict" mode and convert it if there aren't any major issues.
Actually, probably yes if I can use the main shell file without changes. Where can I find documentation for this config?
There is no documentation, as I didn't want to support an external config by default: https://github.com/hexive/sunpaper/issues/3
But, optionally, if a file exists at ~/.config/sunpaper/config, script will read config values from there.
There is no documentation, as I didn't want to support an external config by default:
What made you chose not to support external config by default? Not sure how experienced are you with software engineering, though it's a good practice separating binaries (in this case script) from the config. Though I understand this is your own project, which is amazing by the way!, and I'm glad you shared it freely online :).
My idea was to configure this as systemd timer, and well...systemd is realistically everywhere and I can probably use user's systemd session. This was my deployment idea, and it's easily shareable and reusable across projects & desktop environments
I have no software engineering experience at all! I'm excited to have sunpaper in AUR so please let me know what I can do to support your build.
I added an external configuration file with default settings to /extra/config. If you move that file to ~/.config/sunpaper/config on install everything should work as expected.
If new configuration options are added on future updates, will they need to be handled by me in a special way in order to update existing users external configs?
I also started looking at the script using the bash "strict" method you suggested. Except for a couple unbound variables I think that change will be straight forward. I want to do some more testing to make sure all the optional features are still working as they should.
Thank you again for your time putting this all together.
Anyway, I'm having further issues. sunpaper.sh
is rather..unverbose to me.
I start it (without any config files in my system) and it just silently exits without an error code or anything. Could you increase the logging verbosity?
In #12 I got installation working, more or less (gotta hash out a few things), using systemd's unit & services on the user level...that should work.
IMO this product should require explicit config file, and fail without one (with appropriate error).
I'm using this project as an excuse to learn bash and git so I'll pretty much follow your suggestions as it's pretty clear you have more experience than I do.
Here is an issue #11 where the setwallpaper
utility is not setting wallpaper properly from within systemd. It may possibly related to environmental variables not available? Were you able to get changing paper with a systemd timer on your personal setup?
I can make this a separate issue if need be, but what you may want to consider is to do something like adding a --daemon|-d
flag where it sets daemonMode=True
. Then, instead of the block of code at the end of your script, wrap it in a function called main
and place this at the end of the script"
if [ "$daemonMode" == "True" ]; then
while :; do
main &
sleep 60
done &
else
main
fi
You'd then probably want to add a stop flag that would kill any running sunpaper.sh
instances, but having this functionality internally would probably be the better option than having to rely on cron, systemd, or w/e
Is it really that simple?! I literally have a todo list item over here that says "learn how to make a bash daemon" haha. I'll get this in on the next update.
It might be a little trickier than that. The only thing I can see being problematic with that block is that executing main &
, although forked to the background, does take a few microseconds to run before starting the next sleep timer. After a looooooong time things might start to get skewed. It would probably take months if not years before it becomes a problem though
I was writing PKGBUILD to install this on Arch-based systems:
And got it installed...only to find out the configuration is intertwined with the execution itself. Please, have the script accept parameters either via JSON config file or via environment variables ( and running in bash "strict" mode, http://redsymbol.net/articles/unofficial-bash-strict-mode/ )
That way it would be easier to package into the package manager, run & maintain it.