From 334934d5b54ff9494c293185acda9bb9a9528ac1 Mon Sep 17 00:00:00 2001 From: Pavel Date: Sat, 12 May 2018 00:14:37 +0300 Subject: [PATCH 1/2] Fix problem when card does not recognize if it is already in use --- .../bumblebeeNvidiaUtil.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/freon@UshakovVasilii_Github.yahoo.com/bumblebeeNvidiaUtil.js b/freon@UshakovVasilii_Github.yahoo.com/bumblebeeNvidiaUtil.js index 8902770..c97ae20 100644 --- a/freon@UshakovVasilii_Github.yahoo.com/bumblebeeNvidiaUtil.js +++ b/freon@UshakovVasilii_Github.yahoo.com/bumblebeeNvidiaUtil.js @@ -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() { From da3af4da27169cdde1bf3eb0dbd5c1d1b77f351f Mon Sep 17 00:00:00 2001 From: Pavel Date: Sat, 12 May 2018 00:16:17 +0300 Subject: [PATCH 2/2] Added stderr to output for parsing since on Fedora 28 nvidia-smi output goes to stderr --- .../commandLineUtil.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js b/freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js index b77dc0c..10b9e73 100644 --- a/freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js +++ b/freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js @@ -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;