mirror of
https://github.com/morgan9e/gnome-shell-extension-freon
synced 2026-04-14 16:34:21 +09:00
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user