Skip to content

Commit e5d6bc9

Browse files
authored
Merge pull request #464 from corecoding/develop
Develop
2 parents f8b77dd + b75f7a9 commit e5d6bc9

File tree

4 files changed

+33
-37
lines changed

4 files changed

+33
-37
lines changed

extension.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ var VitalsMenuButton = GObject.registerClass({
2525
}, class VitalsMenuButton extends PanelMenu.Button {
2626
_init(extensionObject) {
2727
super._init(Clutter.ActorAlign.FILL);
28-
28+
2929
this._extensionObject = extensionObject;
3030
this._settings = extensionObject.getSettings();
31-
31+
3232
this._sensorIcons = {
3333
'temperature' : { 'icon': 'temperature-symbolic.svg' },
3434
'voltage' : { 'icon': 'voltage-symbolic.svg' },
@@ -109,7 +109,7 @@ var VitalsMenuButton = GObject.registerClass({
109109

110110
this._initializeMenuGroup(sensor, sensor);
111111
}
112-
112+
113113
for (let i = 1; i <= this._numGpus; i++)
114114
this._initializeMenuGroup('gpu#' + i, 'gpu', (this._numGpus > 1 ? ' ' + i : ''));
115115

@@ -255,7 +255,7 @@ var VitalsMenuButton = GObject.registerClass({
255255
}
256256
);
257257
}
258-
258+
259259
_createHotItem(key, value) {
260260
let icon = this._defaultIcon(key);
261261
this._hotIcons[key] = icon;
@@ -291,7 +291,7 @@ var VitalsMenuButton = GObject.registerClass({
291291
if(sensorName === 'gpu') {
292292
for(let i = 1; i <= this._numGpus; i++)
293293
this._groups[sensorName + '#' + i].visible = this._settings.get_boolean(sensor);
294-
} else
294+
} else
295295
this._groups[sensorName].visible = this._settings.get_boolean(sensor);
296296
}
297297

@@ -417,8 +417,7 @@ var VitalsMenuButton = GObject.registerClass({
417417
}
418418
}
419419
}
420-
if(key === "_gpu#1_domain_number_")
421-
console.error('UPDATING: ', key);
420+
422421
// have we added this sensor before?
423422
let item = this._sensorMenuItems[key];
424423
if (item) {
@@ -565,9 +564,8 @@ var VitalsMenuButton = GObject.registerClass({
565564
arrow_pos = 0;
566565
break;
567566
}
568-
567+
569568
let centered = this._settings.get_boolean('menu-centered')
570-
571569
if (centered) arrow_pos = 0.5;
572570

573571
// set arrow position when initializing and moving vitals
@@ -605,7 +603,7 @@ var VitalsMenuButton = GObject.registerClass({
605603
this._newGpuDetected = true;
606604
return;
607605
}
608-
606+
609607
this._numGpus = parseInt(split[1]);
610608
this._newGpuDetectedCount = 0;
611609
this._newGpuDetected = false;

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"url": "https://github.com/corecoding/Vitals",
1010
"uuid": "Vitals@CoreCoding.com",
11-
"version": 69,
11+
"version": 70,
1212
"donations": {
1313
"paypal": "corecoding"
1414
}

prefs.ui

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,8 @@
12241224
<item translatable="yes">BAT2</item>
12251225
<item translatable="yes">BATT</item>
12261226
<item translatable="yes">CMB0</item>
1227+
<item translatable="yes">CMB1</item>
1228+
<item translatable="yes">CMB2</item>
12271229
<item translatable="yes">macsmc-battery</item>
12281230
</items>
12291231
</object>

sensors.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -377,20 +377,20 @@ export const Sensors = GObject.registerClass({
377377
_queryBattery(callback) {
378378
let battery_slot = this._settings.get_int('battery-slot');
379379

380-
// addresses issue #161
381-
let battery_key = 'BAT'; // BAT0, BAT1 and BAT2
382-
if (battery_slot == 3) {
383-
battery_slot = 'T';
384-
} else if (battery_slot == 4) {
385-
battery_key = 'CMB'; // CMB0
386-
battery_slot = 0;
387-
} else if (battery_slot == 5) {
388-
battery_key = 'macsmc-battery'; // supports Asahi linux
389-
battery_slot = '';
390-
}
380+
// create a mapping of indices to battery paths (from prefs.ui)
381+
const BATTERY_PATHS = {
382+
0: 'BAT0',
383+
1: 'BAT1',
384+
2: 'BAT2',
385+
3: 'BATT',
386+
4: 'CMB0',
387+
5: 'CMB1',
388+
6: 'CMB2',
389+
7: 'macsmc-battery'
390+
};
391391

392392
// uevent has all necessary fields, no need to read individual files
393-
let battery_path = '/sys/class/power_supply/' + battery_key + battery_slot + '/uevent';
393+
let battery_path = '/sys/class/power_supply/' + BATTERY_PATHS[battery_slot] + '/uevent';
394394
new FileModule.File(battery_path).read("\n").then(lines => {
395395
let output = {};
396396
for (let line of lines) {
@@ -507,7 +507,7 @@ export const Sensors = GObject.registerClass({
507507
return;
508508
}
509509
}
510-
510+
511511
this._nvidia_smi_process.read('\n').then(lines => {
512512
/// for debugging multi-gpu on systems with only one gpu
513513
/// duplicates the first gpu's data 3 times, for 4 total gpus
@@ -518,10 +518,9 @@ export const Sensors = GObject.registerClass({
518518
for (let i = 0; i < lines.length; i++) {
519519
this._parseNvidiaSmiLine(callback, lines[i], i + 1, lines.length > 1);
520520
}
521-
522521

523-
// if we've already updated the static info during the last parse, then stop doing so.
524-
// this is so the _parseNvidiaSmiLine function won't return static info anymore
522+
// if we've already updated the static info during the last parse, then stop doing so.
523+
// this is so the _parseNvidiaSmiLine function won't return static info anymore
525524
// and the nvidia-smi commmand won't be queried for static info either
526525
if(!this._nvidia_static_returned) {
527526
this._nvidia_static_returned = true;
@@ -552,13 +551,13 @@ export const Sensors = GObject.registerClass({
552551
this._bad_split_count = 0;
553552

554553
let [
555-
label,
554+
label,
556555
fan_speed_pct,
557-
temp_gpu, temp_mem,
556+
temp_gpu, temp_mem,
558557
mem_total, mem_used, mem_reserved, mem_free,
559558
util_gpu, util_mem, util_encoder, util_decoder,
560559
clock_gpu, clock_mem, clock_encode_decode,
561-
power, power_avg,
560+
power, power_avg,
562561
link_gen_current, link_width_current
563562
] = csv_split;
564563

@@ -580,12 +579,9 @@ export const Sensors = GObject.registerClass({
580579
}
581580
}
582581

583-
584582
const typeName = 'gpu#' + gpuNum;
585583
const globalLabel = 'GPU' + (multiGpu ? ' ' + gpuNum : '');
586-
587584
const memTempValid = !isNaN(parseInt(temp_mem));
588-
589585

590586
this._returnGpuValue(callback, 'Graphics', parseInt(util_gpu) * 0.01, typeName + '-group', 'percent');
591587

@@ -687,7 +683,7 @@ export const Sensors = GObject.registerClass({
687683

688684
_returnStaticGpuValue(callback, label, value, type, format) {
689685
//if we've already tried to return existing static info before or if the option isn't enabled, then do nothing.
690-
if (this._nvidia_static_returned || !this._settings.get_boolean('include-static-gpu-info'))
686+
if (this._nvidia_static_returned || !this._settings.get_boolean('include-static-gpu-info'))
691687
return;
692688

693689
//we don't need to disable static info labels, so just use ordinary returnValue function
@@ -845,7 +841,7 @@ export const Sensors = GObject.registerClass({
845841
_reconfigureNvidiaSmiProcess() {
846842
if (this._settings.get_boolean('show-gpu')) {
847843
this._terminateNvidiaSmiProcess();
848-
844+
849845
try {
850846
let update_time = this._settings.get_int('update-time');
851847
let query_interval = Math.max(update_time, 1);
@@ -859,13 +855,13 @@ export const Sensors = GObject.registerClass({
859855
'clocks.gr,clocks.mem,clocks.video,' +
860856
'power.draw.instant,power.draw.average,' +
861857
'pcie.link.gen.gpucurrent,pcie.link.width.current,' +
862-
(!this._nvidia_static_returned && this._settings.get_boolean('include-static-gpu-info') ?
858+
(!this._nvidia_static_returned && this._settings.get_boolean('include-static-gpu-info') ?
863859
'temperature.gpu.tlimit,' +
864860
'power.limit,' +
865861
'pcie.link.gen.max,pcie.link.width.max,' +
866862
'addressing_mode,'+
867863
'driver_version,vbios_version,serial,' +
868-
'pci.domain,pci.bus,pci.device,pci.device_id,pci.sub_device_id,'
864+
'pci.domain,pci.bus,pci.device,pci.device_id,pci.sub_device_id,'
869865
: ''),
870866
'--format=csv,noheader,nounits',
871867
'-l', query_interval.toString()

0 commit comments

Comments
 (0)