Fix non-root notifications and audio

This commit is contained in:
Matti Viljanen 2020-06-14 17:29:53 +03:00
parent 848e288c83
commit b2ff23aacc
No known key found for this signature in database
GPG key ID: CF32A1495158F888

View file

@ -35,18 +35,21 @@ void Notification::send(QString title, QString body, QString soundFile)
QStringList args; QStringList args;
// Using 'update' works always; it creates a new notification if the ID doesn't match. // Using 'update' works always; it creates a new notification if the ID doesn't match.
args << "-l" << "nemo" << "-c" // notificationtol
<< QString("notificationtool -o update -i %1 -I /usr/share/icons/hicolor/128x128/apps/harbour-batterybuddy.png -A \"Battery Buddy\" \"%2\" \"%3\" \"%2\" \"%3\"").arg(noteID).arg(title).arg(body); args << "-o" << "update"
<< "-i" << noteID
<< "-I" << "/usr/share/icons/hicolor/128x128/apps/harbour-batterybuddy.png"
<< "-A" << "\"Battery Buddy\"" << title << body << title << body;
QProcess aplay; QProcess aplay;
if(!soundFile.isEmpty()) { if(!soundFile.isEmpty()) {
QStringList aplayArgs; QStringList aplayArgs;
aplayArgs << "-l" << "nemo" << "-c" << QString("paplay %1").arg(soundFile); aplayArgs << soundFile;
aplay.start("runuser", aplayArgs); aplay.start("paplay", aplayArgs);
} }
QProcess notificationtool; QProcess notificationtool;
notificationtool.start("runuser", args); notificationtool.start("notificationtool", args);
notificationtool.waitForFinished(); notificationtool.waitForFinished();
QString result(notificationtool.readAll()); QString result(notificationtool.readAll());
@ -66,10 +69,9 @@ void Notification::close()
return; return;
QStringList args; QStringList args;
args << "-l" << "nemo" << "-c" args << "-o" << "remove" << "-i" << noteID;
<< QString("notificationtool -o remove -i %1").arg(noteID);
QProcess proc; QProcess proc;
proc.start("runuser", args); proc.start("notificationtool", args);
proc.waitForFinished(); proc.waitForFinished();
return; return;
} }