1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-15 15:53:55 +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,8 +124,17 @@ function Toaster()
if (require('message-box').notifysend)
{
// Using notify-send
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');
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.stdin.write('su - ' + retVal.username + ' -c "DISPLAY=\'' + retVal.xinfo.display + '\' notify-send \'' + retVal.title + '\' \'' + retVal.caption + '\'"\nexit\n');
}
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
{