mirror of
https://github.com/AstraExt/astra-monitor.git
synced 2025-11-06 15:44:14 +08:00
@@ -1,3 +1,10 @@
|
||||
# Astra Monitor 21 - April 19 2024
|
||||
|
||||
### Bug fixes
|
||||
- Fixed visual bug for system with `scale-monitor-framebuffer` feature disabled [[#110](https://github.com/AstraExt/astra-monitor/issues/110)]
|
||||
|
||||
- Fixed GPU monitoring starting even when the GPU menu is disabled
|
||||
|
||||
# Astra Monitor 20 - April 17 2024
|
||||
|
||||
### Advanced GPU Monitoring
|
||||
|
||||
57
src/bars.ts
57
src/bars.ts
@@ -77,7 +77,9 @@ export default GObject.registerClass(
|
||||
}
|
||||
style += params.style;
|
||||
|
||||
if(params.mini) params.y_align = Clutter.ActorAlign.FILL;
|
||||
if(params.mini) {
|
||||
params.y_align = Clutter.ActorAlign.FILL;
|
||||
}
|
||||
|
||||
super({
|
||||
style: style,
|
||||
@@ -160,8 +162,12 @@ export default GObject.registerClass(
|
||||
|
||||
setStyle() {
|
||||
let styleClass;
|
||||
if(this.layout === 'vertical') styleClass = 'astra-monitor-bars-vertical';
|
||||
else styleClass = 'astra-monitor-bars-horizontal';
|
||||
if(this.layout === 'vertical') {
|
||||
styleClass = 'astra-monitor-bars-vertical';
|
||||
}
|
||||
else {
|
||||
styleClass = 'astra-monitor-bars-horizontal';
|
||||
}
|
||||
|
||||
if(this.mini) styleClass += '-mini';
|
||||
|
||||
@@ -179,21 +185,23 @@ export default GObject.registerClass(
|
||||
try {
|
||||
// eslint-disable-next-line prefer-const
|
||||
let [width, height] = this.get_size();
|
||||
|
||||
if(this.layout === 'vertical' && this.header) {
|
||||
const parentHeight = this.get_parent()!.height;
|
||||
if(height > parentHeight - 6) height = parentHeight - 6;
|
||||
}
|
||||
|
||||
width /= this.scaleFactor;
|
||||
height /= this.scaleFactor;
|
||||
|
||||
let size;
|
||||
if(this.layout === 'vertical')
|
||||
size = height - (this.mini ? 2 : 4); // Remove 2px padding and 2px border
|
||||
else size = width - (this.mini ? 2 : 4); // Remove 2px padding and 2px border
|
||||
|
||||
if(this.layout === 'vertical') {
|
||||
size = height - 4;
|
||||
}
|
||||
else {
|
||||
size = width - 4;
|
||||
}
|
||||
|
||||
if(!values || values.length === 0) {
|
||||
for(let i = 0; i < this.bars.length; i++) {
|
||||
const bar = this.bars[i];
|
||||
for(let l = 0; l < bar.length; l++) bar[l].visible = false;
|
||||
for(let l = 0; l < bar.length; l++) {
|
||||
bar[l].visible = false;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -225,12 +233,17 @@ export default GObject.registerClass(
|
||||
const normalizedValue = value[l].value * size;
|
||||
let fillSize = zero;
|
||||
if(normalizedValue >= 0.5)
|
||||
fillSize = Math.ceil(normalizedValue) / this.scaleFactor;
|
||||
fillSize = Math.ceil(normalizedValue);
|
||||
if(isNaN(fillSize) || fillSize < zero) fillSize = zero;
|
||||
|
||||
if(this.layout === 'vertical')
|
||||
layer.set_position(0, size - start - fillSize);
|
||||
else layer.set_position(start, 0);
|
||||
|
||||
if(this.layout === 'vertical') {
|
||||
const position = size - start - fillSize;
|
||||
layer.set_position(0, position * this.scaleFactor);
|
||||
}
|
||||
else {
|
||||
const position = start;
|
||||
layer.set_position(position * this.scaleFactor, 0);
|
||||
}
|
||||
|
||||
const color = fillSize === 0 ? 'transparent' : this.colors[value[l].color];
|
||||
const style =
|
||||
@@ -265,10 +278,8 @@ export default GObject.registerClass(
|
||||
}
|
||||
}
|
||||
|
||||
const scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
|
||||
|
||||
const roundedSize = this.mini ? 3 : 4;
|
||||
if(totalSize - (start + size) <= roundedSize * scaleFactor) {
|
||||
const roundedSize = (this.mini ? 3 : 4) * this.scaleFactor;
|
||||
if(totalSize - (start + size) <= roundedSize) {
|
||||
if(this.layout === 'vertical') {
|
||||
bordersHelper.topLeft = border;
|
||||
bordersHelper.topRight = border;
|
||||
|
||||
@@ -364,6 +364,8 @@ export default class GpuMonitor extends Monitor {
|
||||
};
|
||||
Config.connect(this, 'changed::gpu-main', updateGpu.bind(this));
|
||||
updateGpu();
|
||||
|
||||
this.updateMonitorStatus();
|
||||
}
|
||||
|
||||
get updateFrequency() {
|
||||
@@ -375,9 +377,18 @@ export default class GpuMonitor extends Monitor {
|
||||
}
|
||||
|
||||
updateMonitorStatus() {
|
||||
const show = Config.get_boolean('gpu-header-show');
|
||||
if(show || this.isListeningFor('gpuUpdate')) this.start();
|
||||
else this.stop();
|
||||
if(Config.get_boolean('gpu-header-show') || this.isListeningFor('gpuUpdateProcessor')) {
|
||||
this.start();
|
||||
}
|
||||
else {
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
|
||||
restart() {
|
||||
if(!Config.get_boolean('gpu-header-show') && !this.isListeningFor('gpuUpdateProcessor'))
|
||||
return;
|
||||
super.restart();
|
||||
}
|
||||
|
||||
reset() {
|
||||
@@ -403,7 +414,7 @@ export default class GpuMonitor extends Monitor {
|
||||
}
|
||||
|
||||
startListeningFor(key: string) {
|
||||
if(key === 'gpuUpdate') {
|
||||
if(key === 'gpuUpdateProcessor') {
|
||||
setTimeout(() => {
|
||||
this.updateMonitorStatus();
|
||||
});
|
||||
@@ -411,12 +422,14 @@ export default class GpuMonitor extends Monitor {
|
||||
}
|
||||
|
||||
stopListeningFor(key: string) {
|
||||
if(key === 'gpuUpdate') {
|
||||
if(key === 'gpuUpdateProcessor') {
|
||||
this.updateMonitorStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private startGpuTask() {
|
||||
Utils.log('startGpuTask!');
|
||||
|
||||
const selectedGpu = Utils.getSelectedGPU();
|
||||
if(!selectedGpu) return;
|
||||
|
||||
@@ -446,7 +459,6 @@ export default class GpuMonitor extends Monitor {
|
||||
|
||||
private stopGpuTask() {
|
||||
if(this.updateAmdGpuTask.isRunning) this.updateAmdGpuTask.stop();
|
||||
|
||||
if(this.updateNvidiaGpuTask.isRunning) this.updateNvidiaGpuTask.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -178,6 +178,14 @@ export default GObject.registerClass(
|
||||
showTooltip() {}
|
||||
|
||||
hideTooltip() {}
|
||||
|
||||
get scaleFactor() {
|
||||
const themeContext = St.ThemeContext.get_for_stage(global.get_stage());
|
||||
if(themeContext.get_scale_factor) {
|
||||
return themeContext.get_scale_factor();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
Config.clear(this);
|
||||
|
||||
@@ -300,8 +300,9 @@ export default GObject.registerClass(
|
||||
const calculateStyle = () => {
|
||||
if(this.ioLayout === 'horizontal') return 'font-size:1em;';
|
||||
const superHeight = this.speedContainer.get_parent()?.height ?? 0;
|
||||
if(superHeight <= 20) return 'font-size:0.65em;';
|
||||
return `font-size:${Math.round(superHeight / 3)}px;`;
|
||||
const scaledHeight = superHeight / this.scaleFactor;
|
||||
if(scaledHeight <= 20) return 'font-size:0.65em;';
|
||||
return `font-size:${Math.round(scaledHeight / 3)}px;`;
|
||||
};
|
||||
const style = calculateStyle();
|
||||
|
||||
|
||||
@@ -822,8 +822,10 @@ export default class ProcessorMenu extends MenuBase {
|
||||
|
||||
const processorGpuShow = Config.get_boolean('processor-gpu');
|
||||
const gpuHeaderShow = Config.get_boolean('gpu-header-show');
|
||||
if(processorGpuShow && !gpuHeaderShow)
|
||||
if(processorGpuShow && !gpuHeaderShow) {
|
||||
Utils.gpuMonitor.listen(this, 'gpuUpdateProcessor', () => {});
|
||||
Utils.gpuMonitor.listen(this, 'gpuUpdate', this.update.bind(this, 'gpuUpdate'));
|
||||
}
|
||||
}
|
||||
|
||||
async onClose() {
|
||||
@@ -840,6 +842,7 @@ export default class ProcessorMenu extends MenuBase {
|
||||
Utils.processorMonitor.unlisten(this, 'loadAverage');
|
||||
|
||||
Utils.gpuMonitor.unlisten(this, 'gpuUpdate');
|
||||
Utils.gpuMonitor.unlisten(this, 'gpuUpdateProcessor');
|
||||
|
||||
this.queueTopProcessesUpdate = false;
|
||||
|
||||
|
||||
@@ -313,8 +313,9 @@ export default GObject.registerClass(
|
||||
if(this.sensorsNum === 1 || this.sensorsLayout === 'horizontal')
|
||||
return 'font-size:1em;';
|
||||
const superHeight = this.valuesContainer.get_parent()?.height ?? 0;
|
||||
if(superHeight <= 20) return 'font-size:0.65em;';
|
||||
return `font-size:${Math.round(superHeight / 3)}px;`;
|
||||
const scaledHeight = superHeight / this.scaleFactor;
|
||||
if(scaledHeight <= 20) return 'font-size:0.65em;';
|
||||
return `font-size:${Math.round(scaledHeight / 3)}px;`;
|
||||
};
|
||||
const style = calculateStyle();
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ export default GObject.registerClass(
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateBars([[{ color: 0, value: usage.usePercentage / 100.0 }]]);
|
||||
this.updateBars([[{ color: 0, value: 1/*usage.usePercentage / 100.0*/ }]]);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -464,8 +464,9 @@ export default GObject.registerClass(
|
||||
const calculateStyle = () => {
|
||||
if(this.ioLayout === 'horizontal') return 'font-size:1em;';
|
||||
const superHeight = this.speedContainer.get_parent()?.height ?? 0;
|
||||
if(superHeight <= 20) return 'font-size:0.65em;';
|
||||
return `font-size:${Math.round(superHeight / 3)}px;`;
|
||||
const scaledHeight = superHeight / this.scaleFactor;
|
||||
if(scaledHeight <= 20) return 'font-size:0.65em;';
|
||||
return `font-size:${Math.round(scaledHeight / 3)}px;`;
|
||||
};
|
||||
const style = calculateStyle();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user