Results 1 to 4 of 4

Thread: Help with Notify-Send not working

  1. #1
    Join Date
    Mar 2008
    Beans
    217

    Help with Notify-Send not working

    I have been trying to get a simple alert show up when I complete a bash script, and it works fine as a regular user. But I have to run the program as sudo, and for some reason, when I do, notify-send fails. Does anyone know why? Is there a way to fix this? Can I tell notify-send to appear on a certain user's active desktop?

    The line in the script is:

    notify-send -u critical -t 0 "Some text here."

    Any help will be appreciated. Thank you!

  2. #2
    Join Date
    May 2010
    Beans
    3,270

    Re: Help with Notify-Send not working

    Try adding an export to set the DISPLAY value. May help

  3. #3
    Join Date
    Dec 2014
    Beans
    2,611

    Re: Help with Notify-Send not working

    notify-send uses the session-dbus to send the notification to a notification daemon. It needs the environment variable DBUS_SESSION_BUS_ADDRESS to have the correct value ('unix:path=/run/user/1000/bus' on my system; '1000' is my numeric user id) and it must be called by the user (the dbus protocol has some authentication mechanism in place). So what you should try in your script is something like
    Code:
    su -c "DBUS_SESSION_BUS_ADDRESS='unix:path=/run/user/UID/bus' notify-send 'blah'" - USER
    Replace UID and USER to fit your situation.

    Holger
    Last edited by Holger_Gehrke; 1 Week Ago at 01:02 PM.

  4. #4
    Join Date
    Mar 2008
    Beans
    217

    Re: Help with Notify-Send not working

    @Holger_Gehrke, that worked perfectly. Thank you so much!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •