jeudi 7 juillet 2016

C++ code not showing notification on top right in Ubuntu 14.04


I'm using libnotify-dev in Ubuntu 14.04. The sample code is running and showing the notification but my code is compiling and running fine on the terminal but is not showing any notification. Why?

...    
using namespace std;

notify_init("Sample");

const int minute=60;
int elapsedTime;
double secdiff;
time_t start,end;
time (&start);

while(true)
{
    time (&end);
    secdiff=static_cast<int>(difftime(end,start));
    elapsedTime=secdiff;
    if(elapsedTime%minute==0)
    {              
        secdiff/=minute;            
        secdiff/=2;
        string str=to_string(secdiff);
        str+=" minute(s) have been passed.";
        NotifyNotification* n = notify_notification_new ("Alert!",str.c_str(),0);
        notify_notification_set_timeout(n, 15000); // 15 seconds
        sleep(18);

    }
}

Aucun commentaire:

Enregistrer un commentaire