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

Zbus error when running under systemd #156

Closed
Ragnyll opened this issue Nov 13, 2022 · 2 comments
Closed

Zbus error when running under systemd #156

Ragnyll opened this issue Nov 13, 2022 · 2 comments

Comments

@Ragnyll
Copy link

Ragnyll commented Nov 13, 2022

Hey all, I'm seeing some confusing behaviour when trying to run this as part of a systemd unit an not sure what I need to install to work correctly.

Basically I am able to call this Notification show as expected with

    Notification::new()
        .summary("Posture Watcher")
        .urgency(notify_rust::Urgency::Critical)
        .body(&format!(
            "Time to change to a {} position",
            next_state.as_ref()
        ))
        .show()?;

when i just run as a bin installed in $HOME/.cargo/bin/myprogram. However if I set up a systemd unit I get the error

Nov 12 23:46:21 blade posture-notifier[443468]: thread 'main' panicked at 'just work: Error { kind: Zbus(Io(Os { code: 2, kind: NotFound, message: "No such file or directory....

This seems kinda similar to #140, but I think this is more so something to do with the user systemd runs under (which i'm pretty sure is just root in this case), but if the only dep is libdbus-1-dev i have a hard time believing that something that varies user to user on desktop linux.

Is there something I need to install under my systemd user? or what's the play here?

@hoodie
Copy link
Owner

hoodie commented Nov 13, 2022

Looks like you are using the zbus dependency, so you don't even need libdbus-1-dev at all. You'd only need this if you built the notify-rust dependency with the d feature, but that is only there as a fallback.
I'm not a huge dbus expert, but I think you need to run as the same user to be able to send notifications. You are basically talking to your desktop-environment (kde/gnome/etc) and that might only accept requests from the same user.

Granted the "No such file or directory" message is confusing, I would assume that is because the underlying implementation uses some proc file (waves hands). But this sounds very similar to #54, so I would say the rule of thumb is "desktop notifications can only be sent by you own user".

@Ragnyll
Copy link
Author

Ragnyll commented Nov 15, 2022

Thanks for the tip @hoodie . I managed to get this working by running it with systemctl --user. So no problem with the crate, just my understanding of systemd.

Thanks again!

I'll close this issue now

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

2 participants