Search code examples
ubuntu-14.04upstart

notfiy-send not showing up with upstart


Problem : notify-send command is not showing up notification even though the log file is created.

Contents of /home/user/test

#!/bin/bash
echo 'test job, reporting...'
while :
do
notify-send 'This is a simple notification Sir'
sleep 30
done

Contents of /etc/init/myjob.conf

description "test job"
start on runlevel [2345]
exec /home/sajal/test

To check for any syntax error :

$ init-checkconf myjob.conf

In order to run the above .config file i used :

$ sudo start myjob

enter image description here

to view the contents of log generated :

$ sudo gedit /var/log/upstart/myjob.log

enter image description here


Solution

  • This is not an Upstart problem at all. You are trying to send Desktop Notifications using system job which is executed in an environment having no refference to you desktop session namely it is missing DBUS_SESSION_BUS_ADDRESS and DISPLAY along with other environmental variables.

    You could use us session job instead (recommended) or gain understanding on Linux permissions, session and environments and define needed enviromental variables in your system job configuration file. You might find some useful hints in those two threads related to sending desktop notifications from system cron job. 1 and 2