mirror of
https://github.com/morgan9e/gnome-shell-extension-freon
synced 2026-04-15 00:44:22 +09:00
fix bumblebee+nvidia if bumblebee not installed, #5
This commit is contained in:
@@ -19,20 +19,26 @@ const BumblebeeNvidiaUtil = new Lang.Class({
|
|||||||
// https://github.com/meden/gse-bumblebee-indicator
|
// https://github.com/meden/gse-bumblebee-indicator
|
||||||
// thank meden!
|
// thank meden!
|
||||||
let virtualDisplay = ':8';
|
let virtualDisplay = ':8';
|
||||||
let configFile = Gio.File.new_for_path('/etc/bumblebee/bumblebee.conf');
|
|
||||||
let contents = configFile.load_contents(null);
|
let bumblebeeConfPath = '/etc/bumblebee/bumblebee.conf';
|
||||||
if (contents[0]) {
|
if(GLib.file_test(bumblebeeConfPath, GLib.FileTest.EXISTS)){
|
||||||
let pattern = /^VirtualDisplay=.*$/m
|
let configFile = Gio.File.new_for_path(bumblebeeConfPath);
|
||||||
let match = new String(pattern.exec(new String(contents)));
|
let contents = configFile.load_contents(null);
|
||||||
virtualDisplay = match.substr(16);
|
if (contents[0]) {
|
||||||
|
let pattern = /^VirtualDisplay=.*$/m
|
||||||
|
let match = new String(pattern.exec(new String(contents)));
|
||||||
|
virtualDisplay = match.substr(16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let lockFilePath = '/tmp/.X' + virtualDisplay + '-lock';
|
||||||
|
if(GLib.file_test(lockFilePath, GLib.FileTest.EXISTS)){
|
||||||
|
this._lockMonitor = Gio.File.new_for_path(
|
||||||
|
lockFilePath).monitor_file(Gio.FileMonitorFlags.NONE, null
|
||||||
|
);
|
||||||
|
this._lockMonitor.id = this._lockMonitor.connect(
|
||||||
|
'changed', Lang.bind(this, this._statusChanged)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let lockFile = '/tmp/.X' + virtualDisplay + '-lock';
|
|
||||||
this._lockMonitor = Gio.File.new_for_path(
|
|
||||||
lockFile).monitor_file(Gio.FileMonitorFlags.NONE, null
|
|
||||||
);
|
|
||||||
this._lockMonitor.id = this._lockMonitor.connect(
|
|
||||||
'changed', Lang.bind(this, this._statusChanged)
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_detectLabel: function() {
|
_detectLabel: function() {
|
||||||
@@ -89,7 +95,8 @@ const BumblebeeNvidiaUtil = new Lang.Class({
|
|||||||
|
|
||||||
destroy: function(){
|
destroy: function(){
|
||||||
this.parent();
|
this.parent();
|
||||||
this._lockMonitor.disconnect(this._lockMonitor.id);
|
if(this._lockMonitor)
|
||||||
|
this._lockMonitor.disconnect(this._lockMonitor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user