Results 1 to 4 of 4

Thread: udev rules

  1. #1
    Join Date
    Jun 2011
    Beans
    8

    udev rules

    I am using udev rules to detect removable drives which executes a script having only this line:
    notify-send "Drive detected".
    Code:
    #!/bin/bash
    notify-send "Drive detected"
    1.My udev rules are perfect.Had them checked
    2.Script is getting executed.Tested it by using touch /tmp/test command in the script.
    3.The script works fine when run manually.
    What is the problem?

  2. #2
    Join Date
    May 2006
    Beans
    1,790

    Re: udev rules

    Quote Originally Posted by jaypatel View Post
    I am using udev rules to detect removable drives which executes a script having only this line:
    notify-send "Drive detected".
    Code:
    #!/bin/bash
    notify-send "Drive detected"
    1.My udev rules are perfect.Had them checked
    2.Script is getting executed.Tested it by using touch /tmp/test command in the script.
    3.The script works fine when run manually.
    What is the problem?
    You don't say what the problem is, but I guess notify-send does something useful when you run the script by hand, and this doesn't happen when it's executed by udev.

    What is notify-send? Is there some difference in the environment of the two different executions, like the DISPLAY variable or something?

  3. #3
    Join Date
    Nov 2007
    Location
    Wisconsin
    Beans
    1,139

    Re: udev rules

    Try sending the notifications to an active display. Scripts run by udev and cron and root don't inherit your user's $DISPLAY environment variable.
    Code:
    DISPLAY=:0.0 notify-send "Drive detected"

  4. #4
    Join Date
    Jun 2011
    Beans
    8

    Re: udev rules

    @Cheesehead.Thanks a lot.Worked like magic

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
  •