Skip to content

Commit

Permalink
Merge pull request #464 from corecoding/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
corecoding authored Jan 20, 2025
2 parents f8b77dd + b75f7a9 commit e5d6bc9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 37 deletions.
18 changes: 8 additions & 10 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ var VitalsMenuButton = GObject.registerClass({
}, class VitalsMenuButton extends PanelMenu.Button {
_init(extensionObject) {
super._init(Clutter.ActorAlign.FILL);

this._extensionObject = extensionObject;
this._settings = extensionObject.getSettings();

this._sensorIcons = {
'temperature' : { 'icon': 'temperature-symbolic.svg' },
'voltage' : { 'icon': 'voltage-symbolic.svg' },
Expand Down Expand Up @@ -109,7 +109,7 @@ var VitalsMenuButton = GObject.registerClass({

this._initializeMenuGroup(sensor, sensor);
}

for (let i = 1; i <= this._numGpus; i++)
this._initializeMenuGroup('gpu#' + i, 'gpu', (this._numGpus > 1 ? ' ' + i : ''));

Expand Down Expand Up @@ -255,7 +255,7 @@ var VitalsMenuButton = GObject.registerClass({
}
);
}

_createHotItem(key, value) {
let icon = this._defaultIcon(key);
this._hotIcons[key] = icon;
Expand Down Expand Up @@ -291,7 +291,7 @@ var VitalsMenuButton = GObject.registerClass({
if(sensorName === 'gpu') {
for(let i = 1; i <= this._numGpus; i++)
this._groups[sensorName + '#' + i].visible = this._settings.get_boolean(sensor);
} else
} else
this._groups[sensorName].visible = this._settings.get_boolean(sensor);
}

Expand Down Expand Up @@ -417,8 +417,7 @@ var VitalsMenuButton = GObject.registerClass({
}
}
}
if(key === "_gpu#1_domain_number_")
console.error('UPDATING: ', key);

// have we added this sensor before?
let item = this._sensorMenuItems[key];
if (item) {
Expand Down Expand Up @@ -565,9 +564,8 @@ var VitalsMenuButton = GObject.registerClass({
arrow_pos = 0;
break;
}

let centered = this._settings.get_boolean('menu-centered')

if (centered) arrow_pos = 0.5;

// set arrow position when initializing and moving vitals
Expand Down Expand Up @@ -605,7 +603,7 @@ var VitalsMenuButton = GObject.registerClass({
this._newGpuDetected = true;
return;
}

this._numGpus = parseInt(split[1]);
this._newGpuDetectedCount = 0;
this._newGpuDetected = false;
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"url": "https://github.com/corecoding/Vitals",
"uuid": "[email protected]",
"version": 69,
"version": 70,
"donations": {
"paypal": "corecoding"
}
Expand Down
2 changes: 2 additions & 0 deletions prefs.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,8 @@
<item translatable="yes">BAT2</item>
<item translatable="yes">BATT</item>
<item translatable="yes">CMB0</item>
<item translatable="yes">CMB1</item>
<item translatable="yes">CMB2</item>
<item translatable="yes">macsmc-battery</item>
</items>
</object>
Expand Down
48 changes: 22 additions & 26 deletions sensors.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,20 +377,20 @@ export const Sensors = GObject.registerClass({
_queryBattery(callback) {
let battery_slot = this._settings.get_int('battery-slot');

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

// uevent has all necessary fields, no need to read individual files
let battery_path = '/sys/class/power_supply/' + battery_key + battery_slot + '/uevent';
let battery_path = '/sys/class/power_supply/' + BATTERY_PATHS[battery_slot] + '/uevent';
new FileModule.File(battery_path).read("\n").then(lines => {
let output = {};
for (let line of lines) {
Expand Down Expand Up @@ -507,7 +507,7 @@ export const Sensors = GObject.registerClass({
return;
}
}

this._nvidia_smi_process.read('\n').then(lines => {
/// for debugging multi-gpu on systems with only one gpu
/// duplicates the first gpu's data 3 times, for 4 total gpus
Expand All @@ -518,10 +518,9 @@ export const Sensors = GObject.registerClass({
for (let i = 0; i < lines.length; i++) {
this._parseNvidiaSmiLine(callback, lines[i], i + 1, lines.length > 1);
}


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

let [
label,
label,
fan_speed_pct,
temp_gpu, temp_mem,
temp_gpu, temp_mem,
mem_total, mem_used, mem_reserved, mem_free,
util_gpu, util_mem, util_encoder, util_decoder,
clock_gpu, clock_mem, clock_encode_decode,
power, power_avg,
power, power_avg,
link_gen_current, link_width_current
] = csv_split;

Expand All @@ -580,12 +579,9 @@ export const Sensors = GObject.registerClass({
}
}


const typeName = 'gpu#' + gpuNum;
const globalLabel = 'GPU' + (multiGpu ? ' ' + gpuNum : '');

const memTempValid = !isNaN(parseInt(temp_mem));


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

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

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

//we don't need to disable static info labels, so just use ordinary returnValue function
Expand Down Expand Up @@ -845,7 +841,7 @@ export const Sensors = GObject.registerClass({
_reconfigureNvidiaSmiProcess() {
if (this._settings.get_boolean('show-gpu')) {
this._terminateNvidiaSmiProcess();

try {
let update_time = this._settings.get_int('update-time');
let query_interval = Math.max(update_time, 1);
Expand All @@ -859,13 +855,13 @@ export const Sensors = GObject.registerClass({
'clocks.gr,clocks.mem,clocks.video,' +
'power.draw.instant,power.draw.average,' +
'pcie.link.gen.gpucurrent,pcie.link.width.current,' +
(!this._nvidia_static_returned && this._settings.get_boolean('include-static-gpu-info') ?
(!this._nvidia_static_returned && this._settings.get_boolean('include-static-gpu-info') ?
'temperature.gpu.tlimit,' +
'power.limit,' +
'pcie.link.gen.max,pcie.link.width.max,' +
'addressing_mode,'+
'driver_version,vbios_version,serial,' +
'pci.domain,pci.bus,pci.device,pci.device_id,pci.sub_device_id,'
'pci.domain,pci.bus,pci.device,pci.device_id,pci.sub_device_id,'
: ''),
'--format=csv,noheader,nounits',
'-l', query_interval.toString()
Expand Down

0 comments on commit e5d6bc9

Please sign in to comment.