-
Notifications
You must be signed in to change notification settings - Fork 62
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
cronjob can't find daemon #164
Comments
I managed to work around the problem, because I had that error too. home/$USER/.config/hypr/hyprland.conf /path/to/hyprland.conf/editor crontab |
I made my own daemon for now the loop file basically calls the background changer and the loop file is called from the hyprland config with the delay. I hope this will be fixed one day with the daemon. https://github.com/moessler-bit/.scripts/tree/main/swww |
So for anyone wondering this is a problem not just with running "swww img ..." with cron but running it with elevated privileges (as root, w/ sudo etc). Hopefully this info will help people looking into the problem |
I am currently learning rust and could try to find the problem once i am more familiar with the language |
So I found the issue (I think?) The But when the rust program tries to read that variable (using
I verified this issue to be persistent across different Rust codebases, so the issue is with the I will try to figure out if this can be fixed in some way but I'm quite new to Rust (like I started learning Rust few days ago lmao) so I encourage someone experienced with Rust to try and fix it |
So that would mean that any rust program that uses the std::env crate doesn't work with sudo privileges |
I think the author isn't using a normal daemon like systemd i think. I have to look into this i don't know too much yet |
So update:
Bad news is that there's probably nothing that can be done to rectify it in this codebase, because this is not an issue with rust, but this is an issue with linux enviroment variables and / or cron daemon.
works on my machine when added as a script that is supposed to be run as a cron job and when run with |
Thanks it works on my machine too, had written a python script to pick random images from specified folders and it was driving me crazy |
as an update, I just ran into this, and had to add |
Note that this behavior isn't even according to XDG spec. I'd suggest adding a fallback to /run/user/UID. For getting the UID I'm not sure whether there's something in std but I know this library works. Would add quite a bit of unnecessary bloat tho. |
I just had a look at the current code for this let runtime_dir = if let Ok(dir) = std::env::var("XDG_RUNTIME_DIR") {
dir
} else {
"/tmp/swww".to_string()
}; This is a terrible default. $XDG_RUNTIME_DIR is /run/user/UID in 99% of cases. We should also use that default. + /tmp is insecure. Wouldn't want other users randomly setting my wallpaper. |
EDIT: actually, no. This is really a problem in the
We can just use rustix's getuid. We already depend on |
#327 implements this. But note that we default to |
I changed the example script that works when i execute it as the logged in user. It tells me the it can't find the socket file when I run it with cron. I also tried to set the XDG_RUNTIME_DIR=/run/user/$(id -u) but it didn't work. I am not an expert so I need a little help with this.
The text was updated successfully, but these errors were encountered: