I checked forum and google but I dont found the answer. I try to add udev rule to disable touchpad when mouse is connected. First i wrote general rule to check it working, but dont. This is the rule:
ACTION=="add", SUBSYSTEM=="input", RUN+="/usr/local/bin/touchpadtoggle.sh"
ACTION=="remove", SUBSYSTEM=="input", RUN+="/usr/local/bin/touchpadtoggle.sh"
this rule is placed in /etc/udev/rules.d/00-touchpad.rules
and this is test bash script:
#!/bin/bash
notify-send "Test"
Bash script work good. If I type "/usr/local/bin/touchpadtoggle.sh" in command line, notification is showed.
Best Answer
The problem is udev runs as root and so runs your script as root, not as you. You'll want this for your real script, but this is why
notify-send
isn't sending you the notification when run by udev. Also theDISPLAY
environment variable will need to be manually set, as udev runs in a minimal environment.Change your script to the following, replacing
$USER
with your username:Also to ensure the new rules were (re)read before, run: