1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 16:23:25 +00:00

Updated notify-send fallback, so that it will only try to su to logged in user if the current user is root.

This commit is contained in:
Bryan Roe
2019-08-22 00:55:39 -07:00
parent a0ffbc1e90
commit b0545c070d
2 changed files with 12 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@@ -124,10 +124,19 @@ function Toaster()
if (require('message-box').notifysend) if (require('message-box').notifysend)
{ {
// Using notify-send // Using notify-send
if (require('user-sessions').whoami() == 'root')
{
// We're root, so we must run in correct context
retVal.child = require('child_process').execFile('/bin/sh', ['sh']); retVal.child = require('child_process').execFile('/bin/sh', ['sh']);
retVal.child.stdin.write('su - ' + retVal.username + ' -c "DISPLAY=\'' + retVal.xinfo.display + '\' notify-send \'' + retVal.title + '\' \'' + retVal.caption + '\'"\nexit\n'); retVal.child.stdin.write('su - ' + retVal.username + ' -c "DISPLAY=\'' + retVal.xinfo.display + '\' notify-send \'' + retVal.title + '\' \'' + retVal.caption + '\'"\nexit\n');
} }
else else
{
// We're a regular user, so we don't need to do anything special
retVal.child = require('child_process').execFile(require('message-box').notifysend.path, ['notify-send', retVal.title, retVal.caption]);
}
}
else
{ {
// Faking notification with ZENITY --info // Faking notification with ZENITY --info
if (require('message-box').zenity.timeout) if (require('message-box').zenity.timeout)