Merge pull request #88 from polter-rnd/master

Fixes 2 bugs
This commit is contained in:
Vasilii
2018-05-12 08:19:34 +03:00
committed by GitHub
2 changed files with 18 additions and 2 deletions

View File

@@ -37,6 +37,13 @@ const BumblebeeNvidiaUtil = new Lang.Class({
this._lockMonitor.id = this._lockMonitor.connect(
'changed', Lang.bind(this, this._statusChanged)
);
// Check if the lock file already exists
// (needed when NVIDIA card is already in use at that point)
if(GLib.file_test(lockFilePath, GLib.FileTest.EXISTS)){
this._detectLabel();
this._active = true;
}
},
_detectLabel: function() {

View File

@@ -22,18 +22,27 @@ const CommandLineUtil = new Lang.Class({
let stdout = new Gio.UnixInputStream({fd: stdoutFd, close_fd: true});
let outReader = new Gio.DataInputStream({base_stream: stdout});
let stderr = new Gio.UnixInputStream({fd: stderrFd, close_fd: true});
let errReader = new Gio.DataInputStream({base_stream: stderr});
GLib.close(stdinFd);
GLib.close(stderrFd);
let childWatch = GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, Lang.bind(this, function(pid, status, requestObj) {
let output = [];
let [line, size] = [null, 0];
while (([line, size] = outReader.read_line(null)) != null && line != null) {
if(line)
output.push(line.toString());
}
stdout.close(null);
while (([line, size] = errReader.read_line(null)) != null && line != null) {
if(line)
output.push(line.toString());
}
stderr.close(null);
GLib.source_remove(childWatch);
this._output = output;
this._updated = true;