1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-03 09:03:48 +00:00

Added support for xmessage, as fallback if zenity and kdialog are not found.

This is needed for Deepin
This commit is contained in:
Bryan Roe
2020-04-26 02:07:39 -07:00
parent cb95c0bbea
commit 2717134c50
3 changed files with 60 additions and 12 deletions

View File

@@ -191,6 +191,17 @@ function linux_messageBox()
return (child.stdout.str.trim() == '' ? null : { path: child.stdout.str.trim() });
})()
});
Object.defineProperty(this, 'xmessage',
{
value: (function ()
{
var child = require('child_process').execFile('/bin/sh', ['sh']);
child.stdout.str = ''; child.stdout.on('data', function (chunk) { this.str += chunk.toString(); });
child.stdin.write("whereis xmessage | awk '{ print $2 }'\nexit\n");
child.waitExit();
return (child.stdout.str.trim() == '' ? null : { path: child.stdout.str.trim() });
})()
});
}
else
{
@@ -312,6 +323,34 @@ function linux_messageBox()
}
});
}
else if (this.xmessage)
{
// title, caption, timeout, layout
ret.child = require('child_process').execFile(this.xmessage.path, ['xmessage', '-center', '-buttons', layout == null ? 'No:1,Yes:2' : 'OK:2', '-timeout', timeout.toString(), '-default', layout==null?'No':'OK', caption], { uid: uid, env: { XAUTHORITY: xinfo.xauthority ? xinfo.xauthority : "", DISPLAY: xinfo.display } });
ret.child.stdout.on('data', function (c) { });
ret.child.stderr.on('data', function (c) { });
ret.child.promise = ret;
ret.child.on('exit', function (code)
{
switch(code)
{
case 2:
this.promise._res();
break;
case 1:
this.promise._rej('denied');
break;
default:
this.promise._rej('timeout');
break;
}
});
}
else
{
ret._rej('Unable to create dialog box');
}
return (ret);
};
}