diff --git a/modules/user-sessions.js b/modules/user-sessions.js index dda0274..92bf78a 100644 --- a/modules/user-sessions.js +++ b/modules/user-sessions.js @@ -653,7 +653,7 @@ function UserSessions() } this.consoleUid = function consoleUid() { - var checkstr = process.platform == 'darwin' ? 'console' : ':0'; + var checkstr = process.platform == 'darwin' ? 'console' : process.env['DISPLAY']; var child = require('child_process').execFile('/bin/sh', ['sh']); child.stdout.str = ''; child.stdout.on('data', function (chunk) { this.str += chunk.toString(); }); @@ -667,12 +667,13 @@ function UserSessions() tokens = lines[i].split(' '); for (j = 1; j < tokens.length; ++j) { - if (tokens[j].length > 0 && tokens[j] == checkstr) + if (tokens[j].length > 0 && (tokens[j] == checkstr || tokens[j] == ('(' + checkstr + ')'))) { return (parseInt(this._users()[tokens[0]])); } } } + throw ('nobody logged into console'); } }