I made a script that displays a notificaiton whenever I unplug the charger. I made the script to run by udev by making a rule in rules.d. The problem is the script run fine but the notification didn't show up. So far I know that the script requires the address of the display server, here is what my rule and script looks like.
export DISPLAY=:0
export XAUTHORITY=/home/user/.Xauthority
/usr/bin/notify-send --urgency=critical -i face-cool "Charger removed"
zenity --info --text 'Happy New Year'
Here is the rule that I created
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_STATUS}=="Discharging", RUN+="/home/user/alertchargerremoved.sh"
Is there any other way to notify myself when the charger is removed, like instead of notification which doesn't require the X server? Do you have any other ideas, how can accomplish this thing?
acpi -a
once per five seconds or so, in case of change in output > show notification. – Jacob Vlijm Dec 11 '16 at 08:53xhost +si:localuser:root
and the script worked, but is it safe to do so? I will be adding this command in startup. – Hemant Yadav Dec 11 '16 at 11:13