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

Doesn't work without sudo #119

Open
c-c-6ypo8 opened this issue Feb 9, 2024 · 1 comment
Open

Doesn't work without sudo #119

c-c-6ypo8 opened this issue Feb 9, 2024 · 1 comment

Comments

@c-c-6ypo8
Copy link

c-c-6ypo8 commented Feb 9, 2024

I don't have sudo in my system and I don't want to use it. So my snap-sync tells this after run without arguments:

root is not in the sudoers file.
root is not in the sudoers file.
Exited due to error on line 163.
exit status: 1
command: sudo -u $u DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus notify-send -a $name "$1" "$2" --icon="dialog-$3"
bash line: 171
function name: notify

@c-c-6ypo8
Copy link
Author

c-c-6ypo8 commented Feb 9, 2024

Also, even if I added root in sudoers, I get another error at line 163 because users command generates root user because I am logged in as root (because of not using sudo). So, your script doesn't respect non-sudo linux use. Also with sudo use it generates error if the root is logged in (because root cannot connect to DISPLAY to get notification). So I've fixed notify function to:

notify() {
    for u in $(users | tr ' ' '\n' | sort -u); do
        if [ $u != 'root' ]; then # I've added this line
          sudo -u $u DISPLAY=:0 \ 
          DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus \
          notify-send -a $name "$1" "$2" --icon="dialog-$3"
        fi
    done
}

And this variant seems to work properly (with root added to sudoers). But fully no-sudo variant still isn't working.

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

1 participant